We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Maybe someone can help me out. I thought I solved the problem, but something else seems to be wrong. I have a project using a 87C51RA+ using only on chip Ram and Rom. I have three _at_ definitions pointing at 0x2000, 0x4000, 0x6000. I have a DIP switch I connected to address 0x6000 which determines the program to run. The program runs OK in the simulator, but on board only parts of the program seem to run. eventhough they more or less use all the same variables. Unfortunately I havn't got a emulator to see what I'm going wrong. Any suggestions on (standard) things people seem to get wrong when things like this happen. I include a piece of code, this is really the only (big) difference between the part that works and the part that doesn't
void timer0(void) interrupt 1 using 3{ d++; m++; TH0 = TH_temp; TL0 = TL_temp; } void delay(x, TH_temp, TL_temp){ m = 0; TH0 = TH_temp; TL0 = TL_temp; while(m < x){} }
suggestions on (standard) things people seem to get wrong - not declaring the shared variables (m, perhaps d) <v>volatile - not initializing memory and/or the variables in question More description of the symptoms -- exactly what does and doesn't happen -- might help. It's hard to guess what your code does without seeing it. Unfortunately I havn't got a emulator to see what I'm going wrong Get an emulator :) Or at least a serial monitor debugger. You've got MON and uVision, right?
Thanks for your reply Drew.... Appreciated. Unfortunately I'm still stuck. I'll include some more code, maybe you'll see something I'm missing. Must be something completely stupid.
uchar volatile selection = 0; volatile uchar k = 0; sbit deresens = P1^3; while(selection == 0x01){ deresens = 0; modus(); op_mode = mode_all[k]; man_in(); } while(selection == 0x02){ deresens = 1; modus(); if(k == 1){ op_mode = 0x00; } if(k == 2){ op_mode = 0x02; man_out(); } }
I thought I'd give some additional information, sorry for the fragmented post. As you can see, part of the listing file.
111 2 while(selection == 0x02){ 112 3 deresens = 1; 113 3 modus(); 114 3 if(k == 1){ 115 4 op_mode = 0x00; 116 4 } 117 3 if(k == 2){ 118 4 op_mode = 0x02; 119 4 man_out(); 120 4 } 121 3 } ; SOURCE LINE # 111 002D E500 R MOV A,selection 002F B4021F CJNE A,#02H,?C0013 ; SOURCE LINE # 112 0032 D293 SETB deresens ; SOURCE LINE # 113 0034 120000 E LCALL modus ; SOURCE LINE # 114 0037 E500 R MOV A,k 0039 B40105 CJNE A,#01H,?C0011 ; SOURCE LINE # 115 003C 900000 E MOV DPTR,#op_mode 003F E4 CLR A 0040 F0 MOVX @DPTR,A ; SOURCE LINE # 116 0041 ?C0011: ; SOURCE LINE # 117 0041 E500 R MOV A,k 0043 B402E7 CJNE A,#02H,?C0009 ; SOURCE LINE # 118 0046 900000 E MOV DPTR,#op_mode 0049 7402 MOV A,#02H 004B F0 MOVX @DPTR,A ; SOURCE LINE # 119 004C 120000 E LCALL man_out ; SOURCE LINE # 120 004F ?C0012: ; SOURCE LINE # 121
Found it.... :) In the above op_mode is an output.... In my code I was reading an output with an " if(op_mode == 0x20)" which apparantly can't be done. Altered the code somewhat and all is well. At least I don't feel completely stupid, I mean, I did find it myself. Anyway thanks for the backup Regards John