Beginner PASM ?
AGCB
Posts: 344
What causes this? This is a slight modification of the PM PASM Blink program.
When loaded it does not start to alternately toggle till about 45 seconds later, then works correctly. Why the long initial delay?
Thanks
Aaron
When loaded it does not start to alternately toggle till about 45 seconds later, then works correctly. Why the long initial delay?
Thanks
Aaron
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
PUB main
cognew(@toggle, 0)
DAT
org 0
toggle mov dira, pin
mov time, cnt
add time, #9
mov outa, out 'start w/ 17 on, 16 off
:loop waitcnt time, delay
xor outa, pin
jmp #:loop
'-----------------------
pin long %11_0000_0000_0000_0000 'pins 16 & 17
out long %10_0000_0000_0000_0000 ' starting outa value
delay long 10_000_000
time res 1

Comments
And what is happening in the 45 seconds? edit: I assume the cnt register is counting up ang rolling over to get back to the original value when time was set
mov cnt, cnt add cnt, #9 waitcnt cnt, advanceIOW it will take exactly 14 cycles (4+4+6). Any insn between the initial move and the final wait has to be accounted for. This is easy for your ordinary insn, if you plan to include hubops you're better off using a catch all offset or restructure your code accordingly. It's all down to what you want to achieve.Correct and that happens to take about 53sec @80MHz.
Is there a different way of adding a short delay that avoids this?
Aaron