More fine-tuning for the frequency.

This commit is contained in:
giomba 2022-10-15 22:51:25 +02:00
parent 1281f0bea6
commit 9a931a44ad

View File

@ -85,28 +85,18 @@ static void vga_vsync_program_init(PIO pio, uint sm, uint offset)
int main() int main()
{ {
// main clock = VCO / divider1 / divider2 = 126MHz
pll_init(pll_sys, 1, 1500 * MHZ, 6, 2);
stdio_init_all(); stdio_init_all();
sleep_ms(5000);
// "draw" an horizontal dotted line (?) // "draw" an horizontal dotted line (?)
for (unsigned int c = 0; c < 5; c++) for (unsigned int c = 0; c < 5; c++)
{ {
frames[0].data[80 * 64 + 30 + c] = 0x55; frames[0].data[80 * 64 + 30 + c] = 0x55;
} }
/*
for (unsigned int c = 0; c < 20; c++)
{
frames[0].data[80 * 128 + 30 + c] = 0x99;
}
*/
// PIO and state machines // PIO and state machines
PIO pio = pio0; PIO pio = pio0;
sleep_ms(5000);
// VGA HSYNC program // VGA HSYNC program
uint offset1 = pio_add_program(pio, &vga_hsync_program); uint offset1 = pio_add_program(pio, &vga_hsync_program);
uint sm1 = pio_claim_unused_sm(pio, true); uint sm1 = pio_claim_unused_sm(pio, true);
@ -114,8 +104,8 @@ int main()
vga_hsync_program_init(pio, sm1, offset1); vga_hsync_program_init(pio, sm1, offset1);
printf("Feeding horizontal sync...\n"); printf("Feeding horizontal sync...\n");
// low pulse is X pixels long, and SM runs at 4x of pixel clock // low pulse is X pixels long, and SM runs at 4x of pixel clock
pio_sm_put_blocking(pio, sm1, 64 * 4); pio_sm_put_blocking(pio, sm1, (64 - 1) * 4);
pio_sm_put_blocking(pio, sm1, 765 * 4); pio_sm_put_blocking(pio, sm1, (776 - 1) * 4);
// VGA VSYNC program // VGA VSYNC program
uint offset2 = pio_add_program(pio, &vga_vsync_program); uint offset2 = pio_add_program(pio, &vga_vsync_program);