Sunday, 12 November 2017

Nucleo STM32 FreeRTOS UART Virtual COM port

This tutorial will show you how to create a Nucleo STM32 UART communications in FreeRTOS. Nucleo STM32 UART communicates with a computer using a virtual COM port. This allows printing in a terminal for debugging in FreeRTOS.

First select the nucleo board.

Enable FreeRTOS.

Select one of the timers as timebase source for FreeRTOS.

Enable UART2. This UART communicates with STLink and the virtual COM port on the computer.

In Project->Settings
Select SW4STM32 IDE

Project->Generate Code

Open OpenSTM32 IDE and import the project.

Open Src->main.c

Add the code to the StartDefaultTask.

Hit the compile button.

Select Debug Configurations.

Add a new debug configuration under Ac6 STM32 debugging.

Click Debug button on the bottom right.

It should open this window.

Then click resume button.

The STM32 code will be running.

After that, open a virtual COM port.

I like to use picocom to view the virtual COM port. The default baudrate is 115200.

picocom -b 115200 /dev/ttyACM0

The code will print "HI" to the terminal.

No comments:

Post a Comment