Medtronic
Full Member level 5
Dear all MyFriends
i need to convert the next code from MikroC into Keil Please Help
thanks in advaced
Code
i need to convert the next code from MikroC into Keil Please Help
thanks in advaced
Code
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 char xx[20],i,y,red,redred,ad1,ad2,no,cnt0=0,stepp=0,run=0,frame=0,rev=0,order,repeat; int shot=0,ad3; void interrupt(){ y=xx[cnt0+0]; for(i=0;i<8;i++){ portd.f0=y.f0; portd.f1=1; portd.f1=0; y=y>>1; } y=xx[cnt0+1]; for(i=0;i<8;i++){ portd.f0=y.f0; portd.f1=1; portd.f1=0; y=y>>1; } y=xx[cnt0+2]; for(i=0;i<8;i++){ portd.f0=y.f0; portd.f1=1; portd.f1=0; y=y>>1; } y=xx[cnt0+3]; for(i=0;i<8;i++){ portd.f0=y.f0; portd.f1=1; portd.f1=0; y=y>>1; } y=xx[cnt0+4]; for(i=0;i<8;i++){ portd.f0=y.f0; portd.f1=1; portd.f1=0; y=y>>1; } y=xx[cnt0+5]; for(i=0;i<8;i++){ portd.f0=y.f0; portd.f1=1; portd.f1=0; y=y>>1; } y=xx[cnt0+6]; for(i=0;i<8;i++){ portd.f0=y.f0; portd.f1=1; portd.f1=0; y=y>>1; } y=xx[cnt0+7]; for(i=0;i<8;i++){ portd.f0=y.f0; portd.f1=1; portd.f1=0; y=y>>1; } y=xx[cnt0+8]; { portd.f0=y.f0; portd.f1=1; portd.f1=0; } portd.f2=1; portd.f2=0; // display register latch content of frame portb.f1=~portb.f1; // invert flasher led. if(rev==0){ cnt0+=9; if(cnt0>=(redred)){ cnt0=0; stepp++; if(stepp==6){ stepp=0; shot=shot+redred+2; cnt0=0; run=0; intcon=0; } } } if(rev==1){ if(stepp<6){ cnt0+=9; if(cnt0>=redred){ cnt0=0; stepp++; if(stepp==6){ cnt0=redred+1; } } } if(stepp>=6){ if(cnt0==0){ cnt0=redred+1; stepp++; if(stepp==12){ stepp=0; shot=shot+redred+2; cnt0=0; run=0; intcon=0; } } if(cnt0>=9){cnt0-=9;} } } //cnt0+=9; if(cnt0>=(redred)){cnt0=0; stepp++;}} //stepp++; // reload next frame data //if(stepp==48){stepp=0; shot=shot+redred+10; cnt0=0; run=0; intcon=0;} //if(porta.f0==1){if(shot>5755){shot=0;}} //else if(porta.f0==0) {if(shot>4605){shot=0;}} intcon.INT0F=0; } void main() { trisd=0; portd=0; trisb=1; portb.f1=0; adcon1=0x07; trisa=1; delay_ms(1000); intcon2.f6=0; I2C1_Init(400000); // initialize I2C communication while(1) { while(run==0){ loop: ///// get order for no. of frames and rev ad3=shot; ad2=ad3; ad1=ad3>>8; I2C1_Start(); // issue I2C start signal I2C1_Wr(0xAE); // send byte via I2C (device address + W) I2C1_Wr(ad1); // send byte (1 st address of EEPROM location) I2C1_Wr(ad2); // send byte (2 nd address of EEPROM location) I2C1_Repeated_Start(); // issue I2C signal repeated start I2C1_Wr(0xAF); // send byte (device address + R) //for(red=0;red<8;red++){ // xx[red]=I2C1_Rd(1); // Read the data (acknowledge) // } xx[0]=I2C1_Rd(0u); // Read the last data (NO acknowledge) I2C1_Stop(); // issue I2C stop signal order=xx[0]; if(order==255){shot=0; goto loop;} /// end of all frames rev.f0=order.f0; // Revers bit at Order.0 order=order>>1; // Divide by 2 frame=order; // Frame = Order / 2 redred=frame*9; // redred--; ///// get frames data ad3=shot+1; ad2=ad3; ad1=ad3>>8; I2C1_Start(); // issue I2C start signal I2C1_Wr(0xAE); // send byte via I2C (device address + W) I2C1_Wr(ad1); // send byte (1 st address of EEPROM location) I2C1_Wr(ad2); // send byte (2 nd address of EEPROM location) I2C1_Repeated_Start(); // issue I2C signal repeated start I2C1_Wr(0xAF); // send byte (device address + R); for(red=0;red<redred;red++){ xx[red]=I2C1_Rd(1); // Read the data (acknowledge) } xx[redred]=I2C1_Rd(0u); // Read the last data (NO acknowledge) I2C1_Stop(); // issue I2C stop signal run=1; intcon=144; } } }
Last edited by a moderator: