ASM: heartbeat (blinking led)
Hello,
After programming a heartbeat (just a blinking led) in spin, I tried programming it in ASM.
But it isn't working![smile.gif](http://forums.parallax.com/images/smilies/smile.gif)
Here is my program:
It also contains the working one, in SPIN. (see PUB start)
Any idea how to fix this?
Kind regards,
Robot Freak
Post Edited (Robot Freak) : 4/14/2008 5:57:11 PM GMT
After programming a heartbeat (just a blinking led) in spin, I tried programming it in ASM.
But it isn't working
![smile.gif](http://forums.parallax.com/images/smilies/smile.gif)
Here is my program:
{{ heartbeat.spin }} [b]CON[/b] [b]_clkmode[/b] = [b]xtal[/b]1 + [b]pll[/b]16x [b]_xinfreq[/b] = 5_000_000 [b]VAR[/b] [b]LONG[/b] stack[noparse][[/noparse]20] [b]BYTE[/b] id [b]PUB[/b] start_asm id := [b]cognew[/b](@asm_start,0) [b]PUB[/b] start id := [b]cognew[/b](beat,@stack) [b]PUB[/b] stop [b]if[/b] id == -1 [b]abort[/b] [b]cogstop[/b](id) id := -1 [b]PRI[/b] beat [b]repeat[/b] ![b]dira[/b][noparse][[/noparse]22] [b]waitcnt[/b](40_000_000 + [b]cnt[/b]) [b]DAT[/b] [b]org[/b] 0 asm_start [b]mov[/b] [b]dira[/b], pin_true 'Set pin 22 output [b]mov[/b] wait_var, [b]cnt[/b] 'Set variable wait_var to cnt [b]add[/b] wait_var, delay_var 'Add delay_var to wait_var :[b]repeat[/b] [b]waitcnt[/b] wait_var, delay_var 'Wait 1/2 sec [b]mov[/b] [b]outa[/b], pin_false 'Set low [b]waitcnt[/b] wait_var, delay_var 'Wait 1/2 sec [b]mov[/b] [b]outa[/b], pin_true 'Set high [b]jmp[/b] :[b]repeat[/b] 'Jump to repeat pin_true [b]long[/b] $1<<22 pin_false [b]long[/b] $1<<22 delay_var [b]long[/b] $28<<6 wait_var [b]long[/b] [b]fit[/b] 496
It also contains the working one, in SPIN. (see PUB start)
Any idea how to fix this?
Kind regards,
Robot Freak
Post Edited (Robot Freak) : 4/14/2008 5:57:11 PM GMT
Comments
PRI beat
dira[noparse][[/noparse]22]~~ ' make pin output
repeat
!outa[noparse][[/noparse]22] ' toggle HIGH and LOW states
waitcnt(40_000_000 + cnt)
and for the ASM - look at the ASM for beginners thread in one of the stickes - there is a post by me starting it, and Beau has an excellent post or two on setting pins...!
James
I'll try what your version does, and I'll search for the example.
Thanks!
pin_true is 1<<22 and pin_false is also 1<<22, pin_false should be 0
your jmp :repeat should also be jmp #:repeat
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
Edit: fixed link
Post Edited (Ale) : 4/15/2008 8:46:53 AM GMT
Glad you got it working
James