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
  • What about this code:

                     ASSUME  DPP3 : SYSTEM
    
    
              EXTRN  ?C_STARTUP : FAR
    
                     REGDEF   R0 - R15
    
    
     ?PR?SLREGELUNG  SECTION  CODE WORD 'FCODE'
    ; line 1: #pragma large
    ; line 2: #pragma src
    ; line 3: #pragma MOD167 FIX167
    ; line 4:
    ; line 5: #include "intrins.h"
    ; line 6: #include "regst10F269.h"
    ; line 7: #include "absacc.h"
    ; line 8: #include "math.h"
    ; line 9:
    ; line 10: sbit Testpin = P3^7;
    ; line 11:
    ; line 12: #include "stdio.h"
    ; line 13:
    ; line 14: void main(void)
    
    	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_();
    	NOP
    ; line 22: 		Testpin = 0;
    	BCLR	Testpin
    ; line 23: 		_nop_();
    	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
    
    By the way: Thanks for your patience.
    Here's a link to the signal I get: http://img141.imageshack.us/my.php?image=signal9bi.jpg

Reply
  • What about this code:

                     ASSUME  DPP3 : SYSTEM
    
    
              EXTRN  ?C_STARTUP : FAR
    
                     REGDEF   R0 - R15
    
    
     ?PR?SLREGELUNG  SECTION  CODE WORD 'FCODE'
    ; line 1: #pragma large
    ; line 2: #pragma src
    ; line 3: #pragma MOD167 FIX167
    ; line 4:
    ; line 5: #include "intrins.h"
    ; line 6: #include "regst10F269.h"
    ; line 7: #include "absacc.h"
    ; line 8: #include "math.h"
    ; line 9:
    ; line 10: sbit Testpin = P3^7;
    ; line 11:
    ; line 12: #include "stdio.h"
    ; line 13:
    ; line 14: void main(void)
    
    	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_();
    	NOP
    ; line 22: 		Testpin = 0;
    	BCLR	Testpin
    ; line 23: 		_nop_();
    	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
    
    By the way: Thanks for your patience.
    Here's a link to the signal I get: http://img141.imageshack.us/my.php?image=signal9bi.jpg

Children