Coley said...
Use it with a pin mask to turn on a specific pin eg outa, #1 <<16 would turn on P16
Actually, it would not. Immediate operands are limited to values between 0 and $1ff, so 1 << 16 is out of range. But you can still use indirect addressing:
or dira,mask16 'Set pin as an output.
or outa,mask16 'Turn pin on.
andn outa,mask16 'Turn pin off.
xor outa,mask16 'Toggle pin.
mask16 long 1 << 16
haha, that's funny you posted this Phil. I was just trying that and would get an error saying the source must be less than $1FF. I was just about to post an "er?" question. Thanks!
The other thing to be careful with using mov for outa, is if the cog has more than 1 output pin, the mov outa affects them all, i.e. the others are set to 0. Its great if thats what you want but often you only want to affect 1 pin.
Well, I'm excited. My first ever PASM program! yay!
org
entry or dira, pinOut
mov time, cnt
add time, duty
mov invduty, period
sub invduty, duty
jmp #:loop
:loop waitcnt time, invduty
or outa, pinOut
waitcnt time, duty
xor outa, pinOut
jmp #:loop 'loop for next cycle
period long 8000
duty long 7000
invduty res 1
time res 1
value res 1
t1 res 1
pinOut long 1<<15
ctraval res 1
Now I have a question... If I set the period to 80,000, the frequency should be 1kHz, right? No. My meter says it's ~166Hz... pretty off if you ask me...
Look at tjz, tjnz for 0 and non-0, djnz, test and cmp instructions
you test and cmp you need to specify to set wz or wc
then you can use
cmp t0,#4 wz
if_z jmp #equal4
it compares t0 to 4 sets the wz flag if they are the same.
if_z says execute the instruction if the wz flag is set, so you would execute the jmp otherwise its a nop
you can set the flags on most instructions and you can use if_z etc on most instructions, so for example
cmp t0,#4 wz
if_z mov t0, #0
would set t0 to 0 if it was 4
I would take a look through fullduplexserial, its a pretty good straightforward piece of pasm that is complex enough to show a lot of stuff. (I would not look at my version of fullduplexserial4fc, I was trying to push the prop and so it re-writes the code on the fly - not just source/dest addresses but the instructions, etc. Once you get used to pasm take a look at some of the stuff you can do if you really want but it does make the code a lot harder for anyone to understand)
Comments
or outa, mask
andn outa,mask
Turns on P0
Use it with a pin mask to turn on a specific pin eg outa, #1 <<16 would turn on P16
Regards,
Coley
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PropGFX Forums - The home of the Hybrid Development System and PropGFX Lite
Post Edited (Coley) : 6/30/2008 11:51:41 PM GMT
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
Post Edited (Phil Pilgrim (PhiPi)) : 6/30/2008 11:36:04 PM GMT
Oops, my bad!
This does work though!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PropGFX Forums - The home of the Hybrid Development System and PropGFX Lite
·
Now I have a question... If I set the period to 80,000, the frequency should be 1kHz, right? No. My meter says it's ~166Hz... pretty off if you ask me...
I need to see some incremental count has reached a threshold, then do something else.
you test and cmp you need to specify to set wz or wc
then you can use
cmp t0,#4 wz
if_z jmp #equal4
it compares t0 to 4 sets the wz flag if they are the same.
if_z says execute the instruction if the wz flag is set, so you would execute the jmp otherwise its a nop
you can set the flags on most instructions and you can use if_z etc on most instructions, so for example
cmp t0,#4 wz
if_z mov t0, #0
would set t0 to 0 if it was 4
I would take a look through fullduplexserial, its a pretty good straightforward piece of pasm that is complex enough to show a lot of stuff. (I would not look at my version of fullduplexserial4fc, I was trying to push the prop and so it re-writes the code on the fly - not just source/dest addresses but the instructions, etc. Once you get used to pasm take a look at some of the stuff you can do if you really want but it does make the code a lot harder for anyone to understand)