How to control pasm repeat loop?
lardom
Posts: 1,659
I just started trying to write pasm code. I wanted to see if I could get an led to blink five times. What I get is some multiple of five. Why is that happening?
CON
CON
_clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR long cog PUB start : okay okay := cog := cognew(@entry, 0) + 1 DAT ' entry org mov CountDown, #1 shl CountDown, #3 or dira, CountDown mov p, #5 mov time, cnt add time, delay :loop or outa, CountDown waitcnt time, delay andn outa, CountDown waitcnt time, delay djnz p, #:loop ' Uninitialized data CountDown long 0 delay long 30000000 p res 1 time res 1
Comments
Andy
Note that this reuses the register that held the cogid instruction to hold the cog id. It doesn't matter that it clobbers the cogid instruction, since the next instruction stops the cog anyway and it will just get reloaded if you restart the cog.
You simply write BASIC code and it spits out pure PASM which can then be grafted to your other PASM code.
PropBASIC is the only reason I use the Prop.
The exception to that is if you want the cog to continue to drive an output pin, because stopping
a cog will release its control of pins - they will go high-impedance unless another cog is also
controlling them.