Post Reply 
Receiver hardware for IR beam (red eye)?
11-29-2023, 09:34 AM
Post: #11
RE: Receiver hardware for IR beam (red eye)?
Very interesting, thanks! I learned two things: .wrap_target does not have to be at the top, and one can start into the PIO directly on a label, and not only at the top.

These are my two state machines:
Code:

.program redeye_carrier_burst

.define NUM_CYCLES 7                ; how many carrier cycles to generate
.define BURST_IRQ 7                 ; which IRQ should trigger a carrier burst
.side_set 1                         ; Side set is the LED pin

.wrap_target
        set X, (NUM_CYCLES - 1) side 0  ; use X to count the number of pulses
        wait 1 irq BURST_IRQ side 0     ; wait for the IRQ, and clear it
cycle_loop:
        nop side 1                      ; Turn LED on
        jmp X-- cycle_loop side 0       ; Turn LED off and loop back
.wrap


Code:

.program redeye_clockout_bursts

.define BURST_IRQ 7                     ; the IRQ used to trigger a carrier burst

.wrap_target
clock_out:
        out X, 1                            ; get the first bit on the left (msb)
        jmp !X burst                        ; bits are inverted, so for a zero, burst
        jmp clock_out                       ; for a one, jump back
burst:
        irq BURST_IRQ                       ; trigger the burst. Jump back is "free" due to wrap.
.wrap
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Receiver hardware for IR beam (red eye)? - Tinue - 11-29-2023 09:34 AM



User(s) browsing this thread: 1 Guest(s)