Skip to main content
Visitor II
September 8, 2005
Question

_nop_ () does not work

  • September 8, 2005
  • 4 replies
  • 1346 views
Posted on September 08, 2005 at 07:08

_nop_ () does not work

    This topic has been closed for replies.

    4 replies

    hal2003Author
    Visitor II
    September 7, 2005
    Posted on September 07, 2005 at 11:43

    Hi forum!

    Second topic today. Think today is not my day.

    I need a small delay in a program. Thus I added _nop_ (); in the source code. But it didn't work. So I wrote the following lines 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. The first one is just ignored. I use µVision2 from Keil.

    Thanks Oliver

    Visitor II
    September 7, 2005
    Posted on September 07, 2005 at 12:24

    Hello,

    This works fine.

    Did you check the generated code? Are the NOP instructions in the LST file?

    Regards,

    hal2003Author
    Visitor II
    September 7, 2005
    Posted on September 07, 2005 at 14:43

    Here's the 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: // E N D E -----

    ; line 27:

    ; line 28:

    END

    And here's a link to the signal I get: http://img141.imageshack.us/my.php?image=signal9bi.jpg

    [ This message was edited by: olfab on 07-09-2005 18:14 ]

    Visitor II
    September 8, 2005
    Posted on September 08, 2005 at 07:08

    Hello,

    As you can see both NOP's are in the code.

    So I guess since you have just a JUMP at the end, you need to add more than just ONE NOP to see a delay.

    I hope this helps you,

    Regards,