STM32L496ZGT6PU STLINK UART communication not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-20 3:17 AM
Goodmorning
I have a new STM32L496ZGT6PU board and I'm currently trying to print a message on the debugger serial terminal, I've followed many official guides step by step failing every time.
In particular, I perform the following:
- Connect the board through a USB type micro-B cable to my laptop (USB PWR connector).
- Create a new STM32 project, selecting the NUCLEO-L496ZG-P board from the board selector -> target language C++ -> initialize the peripherals with their default mode (YES).
- In Pinout & Configuration I go to Connectivity -> USART2 -> Mode Asynchronous and leave the default values.
- Device Configuration Tool Code Generation
- In Src/main.c simply write the following two lines of code in the main() function:
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_UART_Transmit(&huart2, (uint8_t*)"Ciao ", 6, 100);
HAL_Delay(1000);
}
/* USER CODE END 3 */
Then I build the project and start Debug keeping the default settings.
During the debug I create a new command shell console with
- Connection Type: Serial Port
- Serial port: COM6 (my PC seems to correctly recognize the STLINK on this COM port)
- Baudrate: 115200
- Data size: 8
- Parity: none
- Stop bits: 1
By clicking on "resume", the code seems to run, but nothing pops on the serial console.
I tried to use an equal board, change the cable, and change USART interface but this didn't solve the problem.
Solved! Go to Solution.
- Labels:
-
STM32L4 Series
-
UART-USART
-
USB
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-20 3:32 AM
@RiccardoMilici wrote:3. In Pinout & Configuration I go to Connectivity -> USART2 -> Mode Asynchronous and leave the default values.
User manual says it's LPUART1 connected to the VCP:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-20 3:28 AM - edited ‎2024-11-20 4:04 AM
Hello @RiccardoMilici ,
Check your pins configuration and I recommend you follow these articles :
- How to redirect the printf function to a UART for ... - STMicroelectronics Community
- Getting started with UART - stm32mcu
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-20 3:32 AM
@RiccardoMilici wrote:3. In Pinout & Configuration I go to Connectivity -> USART2 -> Mode Asynchronous and leave the default values.
User manual says it's LPUART1 connected to the VCP:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-20 3:53 AM - edited ‎2024-11-20 3:54 AM
Hello,
Simply because USART2 is not connected to STLINK virtual comport on NUCLEO-L496ZG-P board.
Based on the board schematics, you need to use LPUART1 instead:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-20 4:06 AM
@Imen.D wrote:Check your pins configuration and the USART2 alternate functions on which pins are mapped.
It's LPUART1 - not USART2
@Imen.D wrote:I recommend you follow these articles :
- How to redirect the printf function to a UART for ... - STMicroelectronics Community
- Getting started with UART - stm32mcu
Yes, but they should be done in the opposite order:
- First: Getting started with UART - stm32mcu
- Then, if required: How to redirect the printf function to a UART for ... - STMicroelectronics Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-20 4:16 AM - edited ‎2024-11-20 10:46 PM
You are right, I didn't pay attention on the used board.
Thank you @Andrew Neil for pointing out to me.
Thanks
Imen
