cancel
Showing results for 
Search instead for 
Did you mean: 

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

ledi7
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions
STTwo-32
ST Employee

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

9 REPLIES 9
ledi7
Associate III

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.


@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 ...

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.

According to the readme.txt,

@note Debug traces can be enabled/disabled in app_conf.h 

      To get the traces, you have to enable CFG_USB_INTERFACE_ENABLE, with CFG_DEBUG_BLE_TRACE for BLE services traces 
      or with CFG_DEBUG_APP_TRACE for application traces.

      On the PC side:
       - open a terminal window with the following settings:
         baud rate of 115200
         Byte size of 8
         Parity None
         Stop bits 1
         Data Flow Control None

Available Wiki pages:
  - https://wiki.st.com/stm32mcu/wiki/Connectivity:BLE_overview

For more details refer to the Application Note: 
  AN5289 - Building a Wireless application    

https://github.com/STMicroelectronics/STM32CubeWB/tree/master/Projects/P-NUCLEO-WB55.USBDongle/Applications/BLE/BLE_p2pServer

So there's some things to look into ...

 

STTwo-32
ST Employee

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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

 

 

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.