Cognew in PASM
gambrino
Posts: 28
Hello , i read the Propeller programming tutorial and i played the exercises , and i feel that something i didn't understood it good.
1)Can one cog toggle 2 pins simultaneously ? or i should use the parallel processing?
2)How can i toggle 2 pins simultaneously in PASM ? using cognew ? can i write like this to toggle pin16 and 17 simultaneously ? :
Thank you for your help
1)Can one cog toggle 2 pins simultaneously ? or i should use the parallel processing?
2)How can i toggle 2 pins simultaneously in PASM ? using cognew ? can i write like this to toggle pin16 and 17 simultaneously ? :
{{ AssemblyToggle.spin }} 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 :loop waitcnt Time, Delay xor outa, Pin jmp #:loop Toggle1 mov dira, Pin1 mov Time, cnt add Time, #9 :loop waitcnt Time, Delay xor outa, Pin1 jmp #:loop Pin long |< 16 Pin1 long |< 17 Delay long 80_000 Time res 1
Thank you for your help
Comments
Using a 'temp' register, I've used this
Possibly there are better or faster schemes. I'd welcome any myself.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
XOR toggles all Pins which have the Bit set in the Pin Mask. You can toggle 1 to 32 Pins with one XOR.
1<<16 (or |<16) is a more readable form of writing %00000000000000010000000000000000 but in this binary
form, you can see how every bit0..31 of the mask corresponds to a pin PA0..PA31 on the Port.
In PASM all bithandling is done with Bitmasks. Use
XOR to toggle the bits (pins)
OR to set the bits (pins)
ANDN to clear the bits (pins)
MUXxx to set the bits according the C or Z flag value.
Andy