Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3873

General • Re: Very strange problems encountered using the RP2040's PIO to drive a parallel port display

$
0
0
You can't do 'SET Y,118'. The maximum value for SET is 31.

The common way to deal with needing large constants is to load them into one of the other registers - ISR, OSR, X, whichever you aren't using, and then MOV Y,<whichever> in place of SET Y,<value>.

You can load the value into the register with forced-execute instructions before starting the SM, so that the load doesn't use up any of your precious program instructions.

In your case, since it's a purely output application, ISR seems like a good choice for a spare register.

Thank you very much for your reply.

I've changed my code to load the back porch cycle and the data valid cycle using MOV instruction.

Code:

#outputs a byte through the parallel bus@asm_pio(out_init=(PIO.OUT_LOW,) * 8, out_shiftdir=PIO.SHIFT_RIGHT)def parallel_bus_pio():    wrap_target()    # wait for hsync to pulse    wait(0, pin, 13)    wait(1, pin, 13)    # hsync back porch 118 cycles, isr should be loaded with main program    mov(y, isr)    label("back_porch")    nop()    jmp(y_dec, "back_porch")         # 2 clocks per cycle    # data valid for 900 transitions, x should be loaded with main program    mov(y, x)    label("data_valid")    pull()          [0]    out(pins, 8)    [0]    jmp(y_dec, "data_valid")    [1]    wrap()
And, I load ISR and X registers from main program before valid of SMs:

Code:

sm_bus.put(118) # back porch cyclessm_bus.exec("pull()")sm_bus.exec("mov(y, osr)")sm_bus.put(899) # data valid cyclessm_bus.exec("pull()")sm_bus.exec("mov(x, osr)")
But the problem still exists, the back porch cycles are gone. (I used SET instruction for the data valid cycle (900 cycles) before, It works as expected, I don't understand why it works.)
logic_analyzer_02.png

Statistics: Posted by b0wen — Mon Apr 08, 2024 4:01 am



Viewing all articles
Browse latest Browse all 3873

Trending Articles