rp2350 Microcontrollerprogramming using C-SDK
In most cases, the following links drop back to the existng 2040 pages,
until the course switches to the 2350. Code specific to 2350 is linked here for now.
Note: When using protothreads, it appears that there needs to be a 10 mSec sleep
inserted in main before the second core is started.
ece4760 Support
General utilities and information relevant to ece4760 at Cornell.
All examples and student code are written using the Protohreads framework for multithreading.
Protothreads 1.3 (written by Adam Dunkels) to be used 2025
The port to the rp2040 also works with rp2350. The basic protothreads scheme is extended for two cores with support for hardware locks, core-safe semaphores, and core-to-core hardware FIFOs. Protothreads provides a simple, cooperative, thread environment with very fast context switch and low memory overhead. Modified thread dispatcher implements priority scheduling in addition the default round-robin. The code linked below is the full demo with, locks, semaphores, FIFO and both cores running, rp2350 codeanddemo ZIP.
Visual Studio configuration.
Configure VS for editing, programming, debugging using the Pi Debug Probe.
Refer to VScode extension
and the getting started guide.
Add program/reset button
A trivial hardware and software addition simplifies programming.
Superceded by using the debugger.
Graphics
The rp2350 has twice the memory, so there is space for more VGA graphics modes.
There are three changes necessary to port the VGA driver to rp2350. The VGA Hsync and Vsync
PIO programs must have the clock dividers changed from 5 to 6 to account for the faster
system clock (150 on rp2350 vs 125 on rp2040). The RGB PIO program pixel delays need
to extended one cycle/pixel, again for the system clock change. The 4-bit color has two bits of green.
Two bits of green allows more shades of blue and red, and adds orange. Color Map
Arithmetic Systems
The rp2350 has hardware floating point instructions, as well as an improved integer multiplier and divider.
The integer multiplier now produces a full 64 bit result from a 32x32 multiply. This speeds up the fixed point multiply by about a factor of 5.
The pare includes ome test programs attempt to estimate the speed of the operations.
Video below compares float to fix for Mandelbrot set.
Gravitational system in floating point.
Gravity is a long-range force, so the force computations are O(n2) in the
simplest implementation get big quickly. The example animates 150 gravitating particles
at about 140 frames/sec or 300 at 30 frames/sec.
Graphics
Graphics input and output using 640x480 VGA, with optional joystick or encoder wheel.
Mouse interface is also shown in the USB section.
The serial interface is not really graphics, but plays around with color and formatting.
VGA 256 color 319x240. (LWIP compatable, protothreads 1.3, PIO bug fix)
An extension of Hunter's PIO VGA driver for 8 bit color.
Three bits of green, three bits of red, and two bits of blue.
Serial command interface
Modern serial terminal emulators can produce a good looking user interface.
Joystick and encoder wheel with VGA
A simple analog joystick with select button, and a digital encoder wheel with direction and selector buttons.
Mouse controlled graphics.
See USB HID examples below.
External Memory
Everyone needs more memory. FRAM works well for simple files with bandwidth
requirments below about 1.5 Mbyte/sec.
SD card with FatFS has a larger program size overhead, but is compatable with PC read/write of huge files.
USB FLASH drives are exzplained the the USB MSC example below.
LWIP on PicoW
LWIP is the supported TCP/IP stack for the PicoW. LWIP has lots of options and somewhat limited documentation.
This section has lots of examples to exercise some of the options.
Opotions include bringing up the PicoW as an WIFI access point or WIFI station and
data transfer by UDP or TCP.
LWIP and VGA display of NTP and RTC
The
LWIP and Hunter's VGA both use significant hardware. With care they are compatable and run at the same time.
Network Time Protocol (NTP) and the onboard real-time clock (RTC)
The NTP
can be used to automatically set the rp2040 RTC, perhaps daily, to maintain accuracy. The Pico board clock oscillator is rated at ±30 ppm, or accuracy of 3x10-5. Since there are 86400 seconds/day, this means up to 2.6 sec/day drift.
Data array UDP send/receive (station to station thru hotspot)
Sending an array of data allows performance testing as well as understanding of data sizes, and dealing with packet efficiency.
UDP send/receive from desktop (station to station thru hotspot)
UDP
protocol is a simple and fast, but does little error checking. It is therefore useful for data streams where a bad value is not a show stopper. You might send music but not code.
UDP send/receive pico-to-pico. (station to station thru hotspot)
A simple scheme for figuring out IP addresses on the fly allows two picos to send data to each other.
USB on Pico
USB uses the tinyUSB implementation and is fairly big.
There are lots of ways to use it. Examples are your friend.
DSP
More numerical flogging of the M0 architecture, with an emphisis on speed using 16-bit fixed point.
The IIR and FIR sections use design implementations which run completely in C on the the M0, at the
cost some slightly non-optimal designs.
IIR filter designer
Using s1x14 fixed point format. Lowpass, bandpass, and highpass filters design. Plots the Bode plot of the designed filter, and allows the new filter to be used in realtime for audio input.
FIR filter designer
Using s1x14 fixed point format. Lowpass, bandpass, and highpass filters design. Plots the Bode plot of the designed filter, and allows the new filter to be used in realtime for audio input. Also a version for linear frequency plots.
Speech compression/playback from IIR filterbank.
Speech sampled at 12.8 Ksample/sec is sent through 32 MEL-distibuted IIR filters.
The filter powers are sampled every 20 mSec and used to reconstruct speech using DDS.
FFT Spectrogram
Plotting the power spectrum, log power spectrum, and spectrogram of voice signals. The spectrogram actually has enough info to decode what is being said.
DSP development
IIR filters in fixed point s7x24 format. Butterworth lowpass and bandpass filter.