Err on the side of fewer or more NOPs?
BebopALot
Posts: 79
Hi folks, my question refers to the snippet below it. I took Geunther's advice to another member in a thread I found via the forum search engine. I created a time delay routine for the SX28 from this site: http://www.sxlist.com/techref/piclist/codegen/delay.htm. The snippet works great (at least in the SX Sim). The chip basically writes a HI to port RA0 for 12.5us then a low for 12.5 us. Look below to where it says ";2 cycles". This is a mandatory 2 cycle delay in the original code that had 2 NOP commands after it, before I merged it. If I had kept the commands the cycle time in my final version before the low signal would have been a few two long. But when I try to decide when to write the LO signal to RA0 do I eliminate 1 or both NOP commands? As it stands I don't know where within the cycle of the mov w, #%0000 a low occurs. If I keep one NOP command are we really at 2.5 cycles or 2 2/3 cycles until the device actually produces a low signal? The SX28 is assumed to run at 75MHz and total cycles per 12us = 938.
Mov w,#%0001
Mov !ra, w ; go HI bit 1 RA
;936 cycles DELAY 12.5us
mov w, #$EA
mov Hi_Counter1, w
Delay_0:
decsz Hi_Counter1
jmp Delay_0
;2 cycles
nop
;other nop eliminated here
Mov w,#%0000
Mov !ra, w ; go LO bit 1 RA
;936 cycles DELAY 12.5us
mov w, #$EA
mov Lo_Counter1, w
Delay_1:
decsz Lo_Counter1
jmp Delay_1
;2 cycles
;WAVE 2
nop
Mov w,#%0001
Mov !ra, w
THANKS, B.
Post Edited (BebopALot) : 2/1/2006 1:30:23 AM GMT
Mov w,#%0001
Mov !ra, w ; go HI bit 1 RA
;936 cycles DELAY 12.5us
mov w, #$EA
mov Hi_Counter1, w
Delay_0:
decsz Hi_Counter1
jmp Delay_0
;2 cycles
nop
;other nop eliminated here
Mov w,#%0000
Mov !ra, w ; go LO bit 1 RA
;936 cycles DELAY 12.5us
mov w, #$EA
mov Lo_Counter1, w
Delay_1:
decsz Lo_Counter1
jmp Delay_1
;2 cycles
;WAVE 2
nop
Mov w,#%0001
Mov !ra, w
THANKS, B.
Post Edited (BebopALot) : 2/1/2006 1:30:23 AM GMT
Comments
Since it has a resetable counter and multiple breakpoints, I think it might clear up your questions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan