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

_nop_() does not work

Hi forum!
I need a delay in a programm but _nop_() seems not to work. Thus I wrote the following code in the main function where x is an IO pin:

while(1)
{
x = 1;
_nop_();
x = 0;
_nop_();
}

Only the second _nop_() causes a delay but not the first one. µVsioin2 is used. Can anybody help me?

Thanks Fabian

Parents
  • If I understan Walter right, the low time should be longer than the high time.
    Here's the code:

    	main  PROC  FAR
    	GLOBAL  main
    ; FUNCTION main (BEGIN  RMASK = @0x8000)
    ; line 15: {
    ; line 16: 	DP3 = 0x00C0;
    	MOV	DP3,#192
    ; line 17:
    ; line 18: 	while(1)
    ?C0003:
    ; line 19: 	{
    ; line 20: 		Testpin = 1;
    	BSET	Testpin
    ; line 21: 		//_nop_();
    ; line 22: 		Testpin = 0;
    	BCLR	Testpin
    ; line 23: 		//_nop_();
    ; line 24: 	}
    	JMP	cc_UC,?C0003
    ; FUNCTION main (END    RMASK = @0x8000)
    	main  ENDP
     ?PR?SLREGELUNG  ENDS
    
    
    ; line 25: }
    ; line 26:
    ; line 27:
    ; line 28:
    
    	END
    
    And here's a link to a screenshop of the signal: http://img395.imageshack.us/my.php?image=signal25fa.jpg
    The low time is 102ns and the high time 98ns.

    I'm really sorry guys, but I still don't understand what I'm doing wrong.

    Fabian

Reply
  • If I understan Walter right, the low time should be longer than the high time.
    Here's the code:

    	main  PROC  FAR
    	GLOBAL  main
    ; FUNCTION main (BEGIN  RMASK = @0x8000)
    ; line 15: {
    ; line 16: 	DP3 = 0x00C0;
    	MOV	DP3,#192
    ; line 17:
    ; line 18: 	while(1)
    ?C0003:
    ; line 19: 	{
    ; line 20: 		Testpin = 1;
    	BSET	Testpin
    ; line 21: 		//_nop_();
    ; line 22: 		Testpin = 0;
    	BCLR	Testpin
    ; line 23: 		//_nop_();
    ; line 24: 	}
    	JMP	cc_UC,?C0003
    ; FUNCTION main (END    RMASK = @0x8000)
    	main  ENDP
     ?PR?SLREGELUNG  ENDS
    
    
    ; line 25: }
    ; line 26:
    ; line 27:
    ; line 28:
    
    	END
    
    And here's a link to a screenshop of the signal: http://img395.imageshack.us/my.php?image=signal25fa.jpg
    The low time is 102ns and the high time 98ns.

    I'm really sorry guys, but I still don't understand what I'm doing wrong.

    Fabian

Children