Free-running VGA horizontal sync.

This commit is contained in:
giomba 2022-10-12 20:29:11 +02:00
parent 55559b6b89
commit 0f31cfb22d
2 changed files with 9 additions and 14 deletions

View File

@ -103,26 +103,19 @@ int main()
uint sm1 = pio_claim_unused_sm(pio, true); uint sm1 = pio_claim_unused_sm(pio, true);
printf("Starting VGA sync machine on %u...\n", sm1); printf("Starting VGA sync machine on %u...\n", sm1);
vga_sync_program_init(pio, sm1, offset1); vga_sync_program_init(pio, sm1, offset1);
printf("Feeding horizontal sync...\n");
pio_sm_put_blocking(pio, sm1, 63 * 4);
pio_sm_put_blocking(pio, sm1, 775 * 4);
printf("Welcome.\n"); printf("Start!\n");
while (true) while (true)
{ {
for (size_t i = 0; i < sizeof(frames[0].data);) for (size_t i = 0; i < sizeof(frames[0].data);)
{ {
// 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 // feed pixel machine
if (!pio_sm_is_tx_fifo_full(pio, sm0)) if (!pio_sm_is_tx_fifo_full(pio, sm0))
pio_sm_put_blocking(pio, sm0, frames[0].data[i++]); pio_sm_put_blocking(pio, sm0, frames[0].data[i++]);
} }
// printf(".");
// sleep_ms(1000);
} }
} }

View File

@ -9,14 +9,16 @@ loop:
.program vga_sync .program vga_sync
entrypoint_vga_sync: entrypoint_vga_sync:
loop:
pull pull
mov x, osr mov isr, osr
pull
loop:
mov x, isr
set pins, 0 set pins, 0
hsync_pulse: hsync_pulse:
jmp x-- hsync_pulse jmp x-- hsync_pulse
pull
mov x, osr mov x, osr
set pins, 1 set pins, 1
hsync_idle: hsync_idle: