Assembly question
Good Day ,
Do you know why this code works ( blink Led P23 on Quickstart Board)
and this doesnt ( blink the Led P19(!) on Quickstart Board)
Thanks
Do you know why this code works ( blink Led P23 on Quickstart Board)
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
PUB Main
{Launch cog to toggle P16 endlessly}
cognew(@Toggle, 0) 'Launch new cog
DAT
{Toggle P16}
org 0 'Begin at Cog RAM addr 0
Toggle mov dira, port 'Set Pin to output
mov Time, cnt 'Calculate delay time
add Time, #9 'Set minimum delay here
:loop waitcnt Time, Delay 'Wait
xor outa, Pin23 'Toggle Pin
jmp #:loop 'Loop endlessly
Pin16 long |< 16 'Pin number
Pin23 long |< 23 'Pin number
Port long $FFFFFFFF
Delay long 6_000_000 'Clock cycles to delay
Time res 1
and this doesnt ( blink the Led P19(!) on Quickstart Board)
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
PUB Main
{Launch cog to toggle P16 endlessly}
cognew(@Toggle, 0) 'Launch new cog
DAT
Toggle org 0
mov dira,port
rdlong delay, #0
mov t1, cnt ' setup
add t1, delay ' first add
:loop waitcnt t1, delay 'all subsequent adds use the waitcnt
xor outa,Pin23
jmp #:loop
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'delay @80MHz
delay long 80_000_000
delay18ms long 1_440_000
delay200us long 16_000
t1 res 1
cmd byte
data byte
RS long |< 16
RW long |< 17
EN long |< 18
DB4 long |< 19
DB5 long |< 20
DB6 long |< 21
DB7 long |< 22
Pin23 long |< 23
port long $FFFFFFFF
Thanks
Comments
Make the rdlong a comment and your program should toggle with 0,5Hz.
By the way ... with your
mov dira,port
you switch all pins to output-mode. That's a bad idea! You should only switch the pins which are really used as output. Otherwise you can accidently produce shortcuts. For example the PropPlug of course uses one PIN for transmitting data to the propeller. You are lucky that the propeller plug has a protecting resistor which limits the currency.
Another note is that you get the entire set of pins (all 32) as an output with the "mov dira,port" instruction (with port having all bits set to 1 -- as you have it).
EDIT: I see MagIO2 added this on to his post.
[FONT=monospace]port long RS | RW | EN | DB4 | DB5 | DB6 | DB7 | Pin23[/FONT]