Second: the codeīefore we start configuring the USART2 peripheral, we need a test project. We've grabbed all the necessary information related to the hardware needed to start coding. This means that the Nucleo board is configured to use the USART2 peripheral of target MCU. As we can see in the following picture, the USART_TX and USART_RX ports are connected to PA2 and PA3 pins. Now we have to take a look to the Nucleo schematics. Looking to STM32CubeMX tool, we discover that the STM32F401RETx processor has 3 different USARTs: USART1, USART2 and USART6. First: pinoutĪ complex yet flexible MCU like the STM32 provides I/Os that have "overloaded" functionalities.This means that, before we can use a peripheral (in our case, the USART), we need to configure the peripherals associated to corresponding pins. I'll assume the Nucleo-F401RE model, but it should be really easy to rearrange instructions to properly use your specific Nucleo. ST provides the full hardware project of the STM32 Nucleo (the board is designed using the Altium Designer CAD, a professional CAD used in the electronics industry, but you are not required to have a so expensive piece of software to use your Nucleo). But, before we start coding, it could be really useful take a look to the hardware. In this post I'll show you how to properly configure and use the integrated virtual COM port of STM32 Nucleo board. The serial port is mostly useful for two reasons: if you want to debug your firmware printing messages (not strictly necessary with the ARM architecture, since we can also use ARM semihosting) or if you want to exchange commands and messages between your Nucleo board and your PC (perhaps, using a dedicated application you are building). Usually, this device is named something similar to tty.usbmodemXXXX, as shown below. If you use a Linux PC or a Mac, you'll find a new terminal in the /dev directory. When you install the ST-Link drivers, a new device appears in your hardware devices list: the ST-Link Virtual COM port. But, it provides at least another really useful feature: a Virtual COM port. ST Link is mainly designed to allow flashing of target MCU trough the mini-USB interface. return usart_write(platform_get_console(), (u8 *)ptr, len) įinally I start the trace in the SWV console in the IDE but I get no output.Īny idea what I am missing ? What about the core clock of the SWV ? I'm not sure what it corresponds to.As we have seen in the previous tutorial about this new developing board from ST, the STM32 Nucleo provides an integrated ST Link v2.1 interface. If (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) & /* ITM enabled */ I've modified my _write function as follows: static inline unsigned long ITM_SendChar (unsigned long ch) #write 1 to ITM trace privilege register to unmask Stimulus ports 7:0 # Write 0x1 to the ITM Trace Enable Register to enable the Stimulus Port 0 # Write 0x00010005 to the ITM Trace Control Register to enable the ITM with Synchronous enabled and an ATB ID different from 0x00 # Write 0xC5ACCE55 to the ITM Lock Access Register to unlock the write access to the ITM registers # Enable Debug connection in low power modes (DBGMCU->CR) + TPIU for SWV # if the code is not located at default address and does not run by reset. # Reset the chip to get to a known state. I'm not sure it is necessary since TrueStudio/Eclipse allows to setup SWV from the GUI but seems easier this way: # Set character encoding I've modified my startup script as described in STM32L4 reference manual as follows. On Atollic I modified my Debug Configuration to enable SWV with a core clock of 80MHz. I want to migrate to printf using STM32 ITM. Until now I was using printf through UART, thanks to the Virtual COM port. I am developping a Firmware on various STM32L4 Nucleo boards with Atollic Truestudio IDE (basically Eclipse).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |