Sanity check: VGA Controller for Arduino

chesschaser

Oct 20, 2024
10
Joined
Oct 20, 2024
Messages
10
Hi guys,
I'm making a VGA controller board for Arduino, and it looks good to me, but just want a sanity check (especially for the RP2040 section, as I have never used that before) before proceeding to PCB production.
I can't breadboard test it as the frequencies involved are too high.

How it works (or how it's SUPPOSED to work):
The Arduino SPI is nowhere NEAR fast enough for VGA pixel clock timing (25.175MHz), so I am offloading the framebuffer into a SPI SRAM (23LC1024). If MS is pulled low then REFRESH is pulsed, it signals the RP2040 to do the frame update sequence. MS (master select) selects the master the SRAM is connected to. The RP2040 will read the framebuffer and send the data over SPI to the MCP4921 DACs. The LDAC pin is pulsed low only after this is completed, so all three color channels update at once. The voltage followers are for isolation. VREF is chosen to be 1.4V so that the output of the 75 ohm series resistor forming a voltage divider with the one inside the monitor is 0.7V, scaling the analog values to 0V-0.7V, standard VGA.
The firmware on the RP2040 (manually programmed through the W25Q128JVS flash memory chip) will handle pixel clock via PLL, and HYSNC and VYSNC pulse timing). Obviously it is too slow for full resolution, so a reduced resolution will have to do.

EDIT: Part of the circuit seems to be cut off, so I have added it as a second image.
Thanks in advance!!!
 

Attachments

  • second bit.png
    second bit.png
    12.6 KB · Views: 5
  • vga controller for arduino.png
    vga controller for arduino.png
    147.3 KB · Views: 4

Harald Kapp

Moderator
Moderator
Nov 17, 2011
14,273
Joined
Nov 17, 2011
Messages
14,273
Just a thought: Why nor use the RP0240 directly to generate the VGA signal? See e.g. this demo.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
14,273
Joined
Nov 17, 2011
Messages
14,273
I am offloading the framebuffer into a SPI SRAM
I expect a lot of flicker in the resulting image because the SRAM is multiplexed between the Arduino and the RP2040. While the Arduino accesses the SRAM, the RP2040 can't access it and the video will be broken during that time.
To alleviate this, you'd have to use a true dual port RAM or use double buffering with two RAMs where one is read by the RP2040 while the other is being written by the Arduino. Once writing a video page is finished, the roles of the RAMs are swapped at the beginning of a new frame. In this way the RP2040 has always full access to the video RAM and can display the image without interruptions while the Arduino can write a new image at the same time.
 

chesschaser

Oct 20, 2024
10
Joined
Oct 20, 2024
Messages
10
I expect a lot of flicker in the resulting image because the SRAM is multiplexed between the Arduino and the RP2040. While the Arduino accesses the SRAM, the RP2040 can't access it and the video will be broken during that time.
To alleviate this, you'd have to use a true dual port RAM or use double buffering with two RAMs where one is read by the RP2040 while the other is being written by the Arduino. Once writing a video page is finished, the roles of the RAMs are swapped at the beginning of a new frame. In this way the RP2040 has always full access to the video RAM and can display the image without interruptions while the Arduino can write a new image at the same time.
Good idea, and thank you!
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
14,273
Joined
Nov 17, 2011
Messages
14,273
With double buffering: Don't forget to synchronize the write accesss from the Arduino with the frame sync of the RP2040.
  • Once the Arduino has written a frame into the SRAM, it should not write more data until the RP2040 has triggered the RAM swap and reads the previously written new data from the new RAM. Otherwise you risk that the Arduino at least partially overwrites the previous frame.
  • Conversely the RP2040 should not trigger the RAM swap as long as the Arduino is still busy writing new frame data into the RAM. Otherwise the RP2040 will read and display an incomplete frame.
You may check this more detailed info.
 

chesschaser

Oct 20, 2024
10
Joined
Oct 20, 2024
Messages
10
With double buffering: Don't forget to synchronize the write accesss from the Arduino with the frame sync of the RP2040.
  • Once the Arduino has written a frame into the SRAM, it should not write more data until the RP2040 has triggered the RAM swap and reads the previously written new data from the new RAM. Otherwise you risk that the Arduino at least partially overwrites the previous frame.
  • Conversely the RP2040 should not trigger the RAM swap as long as the Arduino is still busy writing new frame data into the RAM. Otherwise the RP2040 will read and display an incomplete frame.
You may check this more detailed info.
Thanks a lot! This is a really good idea. :)
 
Top