This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

can't find what's wrong

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){}
		}

this works ok in the simulator and I think it shouldn't cause any trouble, just grasping at straws maybe.

Any help would be greatly appreciated

Regards

John

Parents
  • 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
    

    It looks like deresens is "set" from here. I have already set the optimiser to "0 = costant folding". I read on the forum that this sometimes could cause a problem. But unfortunately not in my case.

    Regards
    John

Reply
  • 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
    

    It looks like deresens is "set" from here. I have already set the optimiser to "0 = costant folding". I read on the forum that this sometimes could cause a problem. But unfortunately not in my case.

    Regards
    John

Children
  • 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