Skip to content

Instantly share code, notes, and snippets.

@justacec
Created November 4, 2022 08:12
Show Gist options
  • Save justacec/cd0414c28dd762557369b755da479ddc to your computer and use it in GitHub Desktop.
Save justacec/cd0414c28dd762557369b755da479ddc to your computer and use it in GitHub Desktop.
.program morse
.wrap_target
; Ensure start at 0 state
set pins 0
start:
; Pull a 32-bit from the SM0 TX FIFO
pull
; Fill out the scratch buffers
out y 27
jmp !y inter_word_gap
; Decrement Y by 1
jmp y-- sub
sub:
on_state:
out x 1
jmp !x on_start
set x 2
on_start:
set pins 1
loop3:
irq set 4
irq wait 4
jmp x-- loop3
set pins 0
irq set 4
irq wait 4
jmp y-- on_state
set x 1
loop2:
irq set 4
irq wait 4
jmp x-- loop2
; Return to beginning of loop
jmp start
; Execute the inter-word gap of 7 low units (3 units come from the loop2 structure above)
inter_word_gap:
set x 3
loop4:
irq set 4
irq wait 4
jmp x-- loop4
.wrap
.program delay
; This program takes (32+32+1)*9+3 = 653 cycles
.wrap_target
wait 1 irq 4
set y 4 [29] ; Should be 8 for 0.25s
delay1:
nop [31]
jmp y-- delay1 [31]
irq clear 4
.wrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment