I'm trying to set up a VGA sync signal for 640x480, using a Pi Pico 2, and using arduino-pico core, but all i get on my display is "Invalid Format". And i'm sure the correct Pico pins are connected to the correct VGA connector pins, so it has to be the code. Here is the code:
int VSYNC = 17;
int HSYNC = 16;
void setup()
{
pinMode(VSYNC, OUTPUT);
pinMode(HSYNC, OUTPUT);
pinMode(19, OUTPUT);
// Initialize sync signals
gpio_put(VSYNC, HIGH);
gpio_put(HSYNC, HIGH);
gpio_put(19, HIGH);
// put your setup code here, to run once:
}
int line = 0;
void generate_sync()
{
while(true)
{
// Horizontal Sync Timing
// Front Porch
busy_wait_us(0.635);
// Sync Pulse
gpio_put(HSYNC, LOW);
busy_wait_us(3.81);
gpio_put(HSYNC, HIGH);
// Back Porch + Visible Area
busy_wait_us(1.906);
line++;
// Vertical Sync Timing
if (line == 525)
{
line = 0;
}
if (line == 0) // Start VSYNC pulse
{
gpio_put(VSYNC, LOW);
}else if (line == 2) // End VSYNC pulse after 2 lines
{
gpio_put(VSYNC, HIGH);
}
}
}
void loop()
{
generate_sync();
}
Any ideas why the sync signal is not working properly and not being detected properly by the VGA display?