Cornell University ECE4760
Using LWIP with VGA
16
Pi Pico2W rp2350

 

VGA driver and LWIP
Both the VGA driver written by Hunter Adams and the LWIP supplied as part of the C SDK use significant hardware to accelerate operations. The VGA driver uses 3 DMA channels and 3 state machines in one PIO. The LWIP uses 2 DMA channels and two PIO state machines. LWIP defaults to PIO1 (according to notes in SDK 1.5), so the VGA must use PIO0. The LWIP uses the claim mechanism to grab DMA channels. This means that any unused channel may be grabbed. The VGA driver was modified to use the claim system so that it does not step on the channels used by LWIP. Once this small change was made, the two libraries played nicely together. To be safe, the VGA drive also hard-claims three state machines in PIO0. The hard-claim means that vga_init should run before you initialize LWIP.

Real_time clock (AON) display on VGA
Below is a screen capture of the running system showing the AON which was set from the NTP time stamp.
You may want a serial connection to Putty or another terminal to enter commands,but it is not necessary.
When started, the program waits for a connection, then for a NTP response, displays the NTP response,
then sets and displays the AON timer output. If anything goes wrong (e.g. no network) then you will need
the serial terminal for debugging.
The description of VGA and connections are here.

The structure of the program is built around Protothreads, with a thread to get the network time, a thread interfacing to a serial terminal for debugging and commands, a graphics thread and a blink thread just to show that the networking had not killed the threader. Actual low level packet receive is performed by an ISR set up by LWIP. The NTP code is modified slightly from the picow examples repositiory, then converted to run in a thread, with a control semaphore signaled by the serial thread.

Code, ZIP project
Note that the code has defines for WIFI SSID and password that must be specified for your system.
Also note that date is not handled very well if the actual UTC is less than the local time zone.


 


Copyright Cornell University May 31, 2025