The Pi Pico Eurocard is a development board for the Raspberry Pico, designed by shabaz. In this post, I'm presenting four C projects that I've tested with the kit. Three of the examples are not mine. I adapted them (pin assignments), to work with the kit's hardware. We'll test:
|
Prerequisite: you can build and run the pico-examples from the C SDK for Pico.
Project 1: SD Card with FatFS
build from source
carlk3 wrote a port of FatFS for the Pico. I'm adapting it for the EuroCard. Download his port, with examples, from github.
git clone --recurse-submodules https://github.com/carlk3/no-OS-FatFS-SD-SPI-RPi-Pico.git
The project uses the same CMake mechanism as the pico-examples for the C SDK. I'm using the FatFS_SPI example. The CMake file is no-OS-FatFS-SD-SPI-RPi-Pico/example/CMakeLists.txt. One change is required, to select either USB or UART for the print output. I use the EuroCard with the on-board PicoProbe. That taps into the Pico's UART.
pico_enable_stdio_uart(FatFS_SPI_example 1)
pico_enable_stdio_usb(FatFS_SPI_example 0)
image source: shabaz
EuroCard | Pico pin | function |
*CS | IO13 | SPI1 CSn |
MOSI | IO11 | SPI1 TX |
SCLK | IO10 | SPI1 SCK |
MISO | IO12 | SPI1 RX |
You define these pins in hw_config.c:
// Hardware Configuration of SPI "objects" // Note: multiple SD cards can be driven by one SPI if they use different slave // selects. static spi_t spis[] = { // One for each SPI. { .hw_inst = spi1, // SPI component .miso_gpio = 12, // GPIO number (not pin number) .mosi_gpio = 11, .sck_gpio = 10, .set_drive_strength = true, .mosi_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA, .sck_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA, // .baud_rate = 1000 * 1000, //.baud_rate = 12500 * 1000, // The limitation here is SPI slew rate. .baud_rate = 25 * 1000 * 1000, // Actual frequency: 20833333. Has // worked for me with SanDisk. .dma_isr = spi_dma_isr } }; // Hardware Configuration of the SD Card "objects" static sd_card_t sd_cards[] = { // One for each SD card { .pcName = "0:", // Name used to mount device .spi = &spis[0], // Pointer to the SPI driving this card .ss_gpio = 13, // The SPI slave select GPIO for this SD card .set_drive_strength = true, .ss_gpio_drive_strength = GPIO_DRIVE_STRENGTH_2MA, //.use_card_detect = false, // State variables: .m_Status = STA_NOINIT } };
This would be a good time to build the code.
Power
For this example, I'm using the PicoProbe's supply to power the EuroCard and Pico.
Test
Load the firmware to the Pico and insert an SD Card. This can be done with the power on. Connect a terminal program to the PicoProbe's COM port, 115200, 8, 1, N. The example uses escape characters to clear lines, set cursor, format code. The terminal needs to understand these escape characters (e.g.: PuTTY). The built-in terminal of VSCode will not work for this example.
VSCode project, with ul2 executable:
no-OS-FatFS-SD-SPI-RPi-Pico_20221111.zip
Project 2: Rotary Encoder with PIO
This project is a PIO Quadrature Encoder by Jamon Terrell. It uses the PIO state machines to decode the movement / position of the rotary encoder on the EurCard. I 've adapted it for the pins used by shabaz.
When you connect a serial monitor or terminal (the VSCode one works for this example), it will show the position of the encoder, each time you move it. If you are new to PIO, it's an example that uses a fairly simple PIO design.
Use the same power settings as project 1.
For details on this project, check the blog Pico PIO state machine implements a peripheral: Rotary Decoder. The VSCode archive is attached to that post.
Project 3: add a CAN peripheral with PIO
Here, PIO state machines are used to build a CAN block. It's a more complex example - not to build, but to understand. It's an adaption of Kevin O'Connor's can2040 library.
The project requires additional hardware: either a CAN tranceiver, or the poor man's CAN bus. And a counterpart to talk to. The PicoProbe can again be used to power the solution, like project 1. For details, check the blog Pico PIO state machine implements a peripheral: CAN. The VSCode archive is attached to that post.
Project 4: programmable Lab switch
This one uses FreeRTOS, to build a Lab switch that can control a set of relays, FETs, .... The programming language is SCPI. It can be controlled from LabVIEW, pyvisa and other SCPI savvy solutions.
You can test this with the on-board LED, or attach relais to the gpio pins that you control with.
Power
When you use relays, it's best to use the external power option. Don't forget to remove the jumper, to cut the PicoProbe power.
This is a series of articles, step by step. VSCode is attached to each blog. The code for the EuroCard is available on the last post.
Happy Prototyping!