Horizontal sync experiment.

This commit is contained in:
giomba 2022-10-11 20:39:22 +02:00
parent c17a9b1018
commit 55559b6b89
2 changed files with 30 additions and 12 deletions

View File

@ -36,6 +36,7 @@ static void vga_pixel_program_init(PIO pio, uint sm, uint offset)
{
// magic definition of the called function?
pio_sm_config c = vga_free_run_program_get_default_config(offset);
// destination pins for OUT instructions
sm_config_set_out_pins(&c, 22, 1);
pio_gpio_init(pio, 22);
pio_sm_set_consecutive_pindirs(pio, sm, 22, 1, true);
@ -55,7 +56,8 @@ static void vga_pixel_program_init(PIO pio, uint sm, uint offset)
static void vga_sync_program_init(PIO pio, uint sm, uint offset)
{
pio_sm_config config = vga_sync_program_get_default_config(offset);
sm_config_set_out_pins(&config, 20, 2);
// destination pins for SET instructions
sm_config_set_set_pins(&config, 20, 2);
pio_gpio_init(pio, 20);
pio_sm_set_consecutive_pindirs(pio, sm, 20, 2, true);
@ -63,6 +65,8 @@ static void vga_sync_program_init(PIO pio, uint sm, uint offset)
pio_sm_set_clkdiv_int_frac(pio, sm, 1, 0);
pio->sm->shiftctrl = (1 << PIO_SM0_SHIFTCTRL_FJOIN_TX_LSB);
pio_sm_set_enabled(pio, sm, true);
}
@ -102,14 +106,23 @@ int main()
printf("Welcome.\n");
// feed pixel program
while (true)
{
for (size_t i = 0; i < sizeof(frames[0].data); ++i)
for (size_t i = 0; i < sizeof(frames[0].data);)
{
pio_sm_put_blocking(pio, sm0, frames[0].data[i]);
// feed sync machine
if (pio_sm_get_tx_fifo_level(pio, sm1) <= 4)
{
pio_sm_put_blocking(pio, sm1, 63 * 4);
pio_sm_put_blocking(pio, sm1, 775 * 4);
}
// feed pixel machine
if (!pio_sm_is_tx_fifo_full(pio, sm0))
pio_sm_put_blocking(pio, sm0, frames[0].data[i++]);
}
printf(".");
sleep_ms(1000);
// printf(".");
// sleep_ms(1000);
}
}

View File

@ -10,10 +10,15 @@ loop:
entrypoint_vga_sync:
loop:
set x, 31
mov osr, x
out pins, 1 [30]
set x, 0
mov osr, x
out pins, 1 [30]
pull
mov x, osr
set pins, 0
hsync_pulse:
jmp x-- hsync_pulse
pull
mov x, osr
set pins, 1
hsync_idle:
jmp x-- hsync_idle
jmp loop