.program argb_tx .side_set 1 opt .wrap_target pull ; Get data from FIFO mov y, osr ; Store bit count in Y (lower 8 bits) pull ; Get first data word mov x, osr ; Store in X set y, 24 ; Remaining bits in first word (32-8) bit_loop: out pins, 1 ; Shift 1 bit to pins (side-set 0) jmp y--, delay ; Decrement Y, handle delay pull ; Load new data when Y underflows mov x, osr set y, 31 ; Reset bit counter for new word delay: jmp x--, nobit ; Check if current bit is set [1] nop ; [1] Align timing ; Bit=1 pattern (0.8µs high, 0.45µs low) set pins, 1 [99] ; 1 + 99 = 100 cycles (0.8µs) set pins, 0 [55] ; 1 + 55 = 56 cycles (0.448µs) jmp end_bit nobit: ; Bit=0 pattern (0.4µs high, 0.85µs low) set pins, 1 [49] ; 50 cycles (0.4µs) set pins, 0 [105] ; 106 cycles (0.848µs) end_bit: jmp bit_loop ; Total per bit: 156 cycles (1.248µs) post_delay: set pins, 0 ; 70µs low period set y, 8749 ; (70µs / 8ns) - 1 = 8749 cycles delay_loop: jmp y--, delay_loop irq 0 ; Signal completion .wrap