Created
February 3, 2012 18:04
-
-
Save mbparks/1731428 to your computer and use it in GitHub Desktop.
Propeller Assembly for LED Strobe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{strobe LEDs pin 16..19 on COG0 and scan pin 23..20 on COG1} | |
CON | |
_clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz | |
_xinfreq = 5_000_000 | |
PUB StrobeLEDs | |
cognew(@_StrobeLEDRight, 0) | |
cognew(@_StrobeLEDLeft, 0) | |
DAT | |
{Strobe LEDRight Pins 16..19 ----------------------------------------------} | |
org 0 | |
_StrobeLEDRight mov dira, InitPins | |
mov Time, cnt | |
add Time, #$f | |
:init mov outa, Pin16 | |
:uploop waitcnt Time, DelaySlow | |
shl outa, #1 | |
and outa, Pin19 nr, wz | |
if_nz jmp #:downloop | |
jmp #:uploop | |
:downloop waitcnt Time, DelayFast | |
shr outa, #1 | |
and outa, Pin16 nr, wz | |
if_nz jmp #:uploop | |
jmp #:downloop | |
Pin16 long |< 16 | |
Pin19 long |< 19 | |
InitPins long %00000000_11111111_00000000_00000000 | |
DelayFast long 10_000_000 | |
DelaySlow long 15_000_000 | |
Time res 1 | |
{Strobe LEDLeft Pins 23..20 ---------------------------------------------------} | |
org 0 | |
_StrobeLEDLeft mov dira, InitPins2 | |
mov Time2, cnt | |
add Time2, #$f | |
:init mov outa, Pin23 | |
:downloop waitcnt Time2, DelaySlow2 | |
shr outa, #1 | |
and outa, Pin20 nr, wz | |
if_nz jmp #:uploop | |
jmp #:downloop | |
:uploop waitcnt Time2, DelayFast2 | |
shl outa, #1 | |
and outa, Pin23 nr, wz | |
if_nz jmp #:downloop | |
jmp #:uploop | |
Pin23 long |< 23 | |
Pin20 long |< 20 | |
InitPins2 long %00000000_11111111_00000000_00000000 | |
DelayFast2 long 10_000_000 | |
DelaySlow2 long 15_000_000 | |
Time2 res 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment