Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

convert a code from MikroC into Keil

Status
Not open for further replies.

Medtronic

Full Member level 5
Joined
May 19, 2005
Messages
246
Helped
29
Reputation
58
Reaction score
16
Trophy points
1,318
Location
Egypt
Activity points
2,699
Dear all MyFriends

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:

Don't expect someone doing that for you. Just show what errors are happening which you can't solve so that we can assist you.
 

first problem

rev.f0=order.f0; // Revers bit at Order.0

how can implemented at keil ?
 

Code:
// declare
sbit  rev_0     =   rev^0  ;  
sbit  order_0  =   order^0  ;  

// assign
rev_0     = order_0  ;
 

Error c202 'rev' : udefined identefire
 

Very dirty code. I don't think I will try mirgate it to keil even for huch money.
 

The code is PIC code and you are asking to port it to 8051 code. Porter has to study the piece of code and convert it to Keil code. Nobody will do it for you.

Instead use mikroC PRO PIC Compiler and use the code you have posted.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top