
#Minicom tutorial serial
Since the default configuration in the SDK is to use the UART0 as the serial port, there is nothing significant in this ‘CMakeLists.txt’ file. I copied the contents of ‘CMakeLists.txt’ for your reference. In the ‘serial’ directory of ‘hello_world’ directory, open the ‘CMakeLists.txt’ file using vim. Without even modifying the source code, you can essentially enable UART or USB as serial output just by configuring the ‘CMakeLists.txt’ file. The difference lies in the corresponding ‘CMakeLists.txt’ file in each directory. The contents of ‘hello_usb.c’ are exactly the same as that of ‘hello_serial.c’. In fact, if you open the ‘usb’ directory in the ‘hello_world’ directory, you can see two files: ‘CMakeLists.txt’ and ‘hello_usb.c’. Using CMake directives, we can set the output of serial to either UART or USB CDC (or both). The reason for this it is configured in CMake. If you notice the code, there is nothing that specifies whether to use UART or USB. After some hardware initialization (for UART or USB), the program prints ‘Hello, world!’ text continuously with a delay of 1000 ms.
#Minicom tutorial code
In the previous tutorial, we explored the ‘blink’ directory (and the corresponding source files).įor your reference, I copied the code below. In the ‘pico-examples’ directory (which is in /home/pi/pico), you can see the list of all the examples organized into several directories. In that tutorial, I discussed all the necessary steps for setting up your Raspberry Pi (this is Raspberry Pi Computer not the Pico) like downloading the tools, SDK, examples and programming Pico with a Blinky example. Before proceeding further, if you haven’t gone through the initial setup for Programming Raspberry Pi Pico with C using C SDK, then I strongly suggest you to refer to the previous tutorial called ‘Programming Raspberry Pi Pico with C’. With the brief introduction to Raspberry Pi Pico’s Serial Programming, let us no proceed to explore the examples for serial output.

Take a look at the pinout of Raspberry Pi Pico in the ‘Getting Started with Raspberry Pi Pico’ tutorial for all the possible GPIO Pins that can be configured as UART0 or UART1 pins.

NOTE: Pico SDK has a board configuration file called ‘pico.h’, which sets some of the important pins as default for different operations like UART, on-board LED, I 2C, SPI etc.Īccording to this board configuration file, UART0 is the default UART Peripheral and the default UART0_TX Pin is GPIO 0 (GP0) and UART0_RX Pin is GPIO 1 (GP1). When you use the ‘printf’ function to print data, the default serial port is UART and in that UART0 peripheral is used. Raspberry Pi Pico has two UART peripherals: UART0 and UART1.

The serial input and output of Raspberry Pi Pico can be either UART or USB CDC. The beautiful thing about the Raspberry Pi Pico Serial C SDK is that it defines the ‘stdio’ style functions like ‘printf’ for us to use.īefore proceeding with programming Raspberry Pi Pico Serial Port, we have to understand a little bit about Raspberry Pi Pico’s Serial input and output. The important point here is not the text that is printed through the serial port but the process involved for Raspberry Pi Pico to transfer data to the serial port.
