Skip to main content
Associate III
January 21, 2025
Solved

Send trace information to USART2 instead of USART1 in BLE_p2pServer example?

  • January 21, 2025
  • 4 replies
  • 1131 views

Hi,

with the BLE_p2pServer example for STM32WBA55, i want to change the interface from USART1 to USART2. How can i use the trace information like

2025-01-21_11h25_29.png

with USART2?

Best answer by STTwo-32

Hello @ledi7 

To send the trace information to USART2 instead of USART1 in the BLE_P2PServer app for the Nucleo-WBA55CG you have to:

  • Open the .ioc file of the project.
  • Enable USART2.
  • Go to the STM32_WPAN middleware>Configurations>Platform Settings>Serial Link for Logs>Found Solutions and select USART2

STTwo32_0-1737459666719.png

Best Regards.

STTwo-32

4 replies

Andrew Neil
Super User
January 21, 2025
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
ledi7Author
Associate III
January 21, 2025

Hi Andrew,

Thanks for the information, but this is not what I want to do. I am using the BLE_p2pServer example for WBA55 and there is already a lot of log information here that I want to use and which is handled in stm32_adv_trace.c for example. This works for USART1, but I want to output this information to USART2. There must be a definition somewhere where I can define the interface for the output.

Andrew Neil
Super User
January 21, 2025

@ledi7 wrote:

there is already a lot of log information here that I want to use and which is handled in stm32_adv_trace.c .


So the question was: does that handling use printf ?

If it does, then the link shows you how that works and, thus, how to change it to a different output device.

If not, then just look at the stm32_adv_trace.c code to see where it does handle its UART, and change that ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
ledi7Author
Associate III
January 21, 2025

No, printf is not used here. I tried to find some hints in stm32_adv_trace.c or log_module.c but unfortunately without success.

STTwo-32
STTwo-32Best answer
Technical Moderator
January 21, 2025

Hello @ledi7 

To send the trace information to USART2 instead of USART1 in the BLE_P2PServer app for the Nucleo-WBA55CG you have to:

  • Open the .ioc file of the project.
  • Enable USART2.
  • Go to the STM32_WPAN middleware>Configurations>Platform Settings>Serial Link for Logs>Found Solutions and select USART2

STTwo32_0-1737459666719.png

Best Regards.

STTwo-32

ledi7Author
Associate III
January 22, 2025

Hello @STTwo-32 ,

Thanks for the information! It works, but only if BLE is not activated (no advertising, no BLE connection). I use the same settings for USART2 as for USART1 with 19200 Baud. The NVIC priorities are also the same.

2025-01-22_09h10_50.png

When I send a byte from HTerm to USART2, I use the Rx callback function in usart_if.c to trigger the task for a notification event (just like when pressing Button1 on the NUCLEO board).

static void UsartIf_RxCpltCallback(UART_HandleTypeDef *huart)
{
 /* USER CODE BEGIN UsartIf_RxCpltCallback 1 */
 UTIL_SEQ_SetTask( 1<<CFG_TASK_SEND_NOTIF_ID, CFG_SEQ_PRIO_0);
 /* USER CODE END UsartIf_RxCpltCallback 1 */

 RxCpltCallback(&charRx, 1, 0);
 HAL_UART_Receive_IT(&huart2, &charRx, 1);

 /* USER CODE BEGIN UsartIf_RxCpltCallback 2 */

 /* USER CODE END UsartIf_RxCpltCallback 2 */
}

If no advertising or no ble connection is active, I get the log information (here i send a byte four times via HTerm) without errors:

2025-01-22_09h44_05.png

But when advertising or a BLE connection is active, I usually get confused characters as log information. Here, i also send a byte four times when a BLE connection is established:

 

2025-01-22_09h49_41.png

 

 

STTwo-32
Technical Moderator
January 22, 2025

This is completely a different question. You are not using the USART2 for getting trace information, you are trying to send data from your external system (serial interface) to USART interface and then you want to share it throw BLE. This Completely different from the original request. So, please close this one (by selecting a solution for the original request) and open a New one with a Full configuration, if possible, about what you have done and what you want to do. Also, please try to use only one ST community account to avoid answering twice.

Best Regards.

STTwo-32

Andrew Neil
Super User
January 22, 2025
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.