Hi All,
I have recently been working on building a simple VGA gfx card, I have done one as TTL circuity, one via FPGA and now trying with the Pi Pico.
I know this has been done previously, but wanted to try and work through it without ripping off someone else's work.
Right now I'm just trying to get the HSYNC and VSync signals working with the right timing.
I have the HSYNC running from on of the PIO state machines and validated the timing on the scope.
Now, I have written a separate function is asm for the VSYNC signal on another state machine, I either need both state machines to be perfectly in sync from the start, or I need the HSYNC SM to pass a signal to the VSYNC SM.
I have tried this by using one of the HSYNC output pins within a wait command. It never seems to trigger, I never see anything on the VSYNC pin (19) other than it being stuck high.
Can anyone give me a pointer on where I should look? Im focusing on the wait not being triggered, is that right or have I messed up something more fundamental?
I have recently been working on building a simple VGA gfx card, I have done one as TTL circuity, one via FPGA and now trying with the Pi Pico.
I know this has been done previously, but wanted to try and work through it without ripping off someone else's work.
Right now I'm just trying to get the HSYNC and VSync signals working with the right timing.
I have the HSYNC running from on of the PIO state machines and validated the timing on the scope.
Now, I have written a separate function is asm for the VSYNC signal on another state machine, I either need both state machines to be perfectly in sync from the start, or I need the HSYNC SM to pass a signal to the VSYNC SM.
I have tried this by using one of the HSYNC output pins within a wait command. It never seems to trigger, I never see anything on the VSYNC pin (19) other than it being stuck high.
Can anyone give me a pointer on where I should look? Im focusing on the wait not being triggered, is that right or have I messed up something more fundamental?
Code:
from machine import Pin, mem32import utimeimport rp2# Define the base address of the PIO control registerPIO_BASE = 0x50200000PIO_CTRL = PIO_BASE + 0x00@rp2.asm_pio(set_init=(rp2.PIO.OUT_LOW, rp2.PIO.OUT_LOW, rp2.PIO.OUT_LOW))def h(): wrap_target() set(pins, 0b010) [19] nop() [19] nop() [19] nop() [19] nop() [19] nop() [19] nop() [19] nop() [19] nop() [19] nop() [19] #200 nop() [9] #210 set(pins, 0b000) [19] nop() [11] set(pins, 0b010) [19] set(pins, 0b110) [1] wrap()@rp2.asm_pio(set_init=(rp2.PIO.OUT_LOW))def v(): wrap_target() wait(0, gpio, 18) set(pins, 1) [19] mov(x, 29) # Load counter with 329 (for 580 cycles) label("loop") nop() [18] jmp(x_dec, "loop") # Decrement counter and loop if not zero set(pins, 0) [3] nop() [2] wrap()sm0 = rp2.StateMachine(0, h, freq=10_000_000, set_base=machine.Pin(16))sm1 = rp2.StateMachine(1, v, freq=10_000_000, set_base=machine.Pin(19))while True: # Synchronize both state machines by setting the ctrl register directly mem32[PIO_CTRL] |= (1 << 0) | (1 << 1) # Start sm0 and sm1 simultaneously
Statistics: Posted by djh82uk — Sat Mar 08, 2025 10:15 pm — Replies 2 — Views 72