cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WL55 uart error with RF

Son, Dong-Seong
Associate III

Hi I am testing with STM32WL55CCU6.

When I use only uart1, uart1 works well.

but when I use uart1 and RF(LoRa) send, MCU does not work.

I coded that MCU transmit some message using uart to terminal per second.

MCU continues to work fine.

but I added some code that MCU transmit some data using LoRa to remote device per second.

A message is output to the terminal a few times, then no more output,

and the mcu does not work.

I think there are some problem between uart and RF.

​Does your library 1.1.0 have some problem?

Below are some part of my code.

1. init

  MX_GPIO_Init();

  MX_I2C2_Init();

  MX_SUBGHZ_Init();

  MX_USART1_UART_Init();

  MX_USART2_UART_Init();

  MX_I2C3_Init();

  MX_RTC_Init();

  MX_TIM16_Init();

  /* USER CODE BEGIN 2 */

HAL_TIM_Base_Start_IT(&htim16);

 MX_SubGHz_Phy_Init();

2. uart callback

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {

if (huart->Instance == USART1) {

loadReceiveConsoleData(uart1_data);

HAL_UART_Receive_IT(&huart1, &uart1_data, 1);

}

else if(huart->Instance == USART2) {

HAL_UART_Receive_IT(&huart2, &uart2_data, 1);

}

}

3. rf init

void SubghzApp_Init(void)

{

 /* USER CODE BEGIN SubghzApp_Init_1 */

 /* USER CODE END SubghzApp_Init_1 */

 /* Radio initialization */

 RadioEvents.TxDone = OnTxDone;

 RadioEvents.RxDone = OnRxDone;

 RadioEvents.TxTimeout = OnTxTimeout;

 RadioEvents.RxTimeout = OnRxTimeout;

 RadioEvents.RxError = OnRxError;

 Radio.Init(&RadioEvents);

 // USER CODE BEGIN SubghzApp_Init_2

 Radio.SetChannel(RF_FREQUENCY);

 Radio.SetTxConfig(MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,

          LORA_SPREADING_FACTOR, LORA_CODINGRATE,

          LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,

          true, 0, 0, LORA_IQ_INVERSION_ON, TX_TIMEOUT_VALUE);

 Radio.SetRxConfig(MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,

          LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,

          LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,

          0, true, 0, 0, LORA_IQ_INVERSION_ON, true);

 Radio.SetMaxPayloadLength(MODEM_LORA, MAX_APP_BUFFER_SIZE);

 int random_delay = (Radio.Random()) >> 22; // 10bits random e.g. from 0 to 1023 ms

 // starts reception

 Radio.Rx(RX_TIMEOUT_VALUE + random_delay);

 UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_SubGHz_Phy_App_Process), UTIL_SEQ_RFU, RF_Process);

/* USER CODE END SubghzApp_Init_2 */

}

Can you resolve the problem??

I added all source

Please help me~~~~~

8 REPLIES 8
Bruno_ST
ST Employee

Hi @Son, Dong-Seong​ 

On my point of view the timer are not working in the projet you have shared ? The timer_if.c is not implement like under LoRaWAN\LoRaWAN_End_Node\Core\Src\timer_if.c. Do you know why ? Did you create you projet with CubeMX ?

Bruno

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.

Son, Dong-Seong
Associate III

Hi. Bruno_ST

Thank you for your response.

I didnot use timer_if.c for timer.

I use timer16 for only HAL_Delay().

Should I use the timer_if.c file for the timer of RF

I created my project with CubeMX on ​STM32CubeIDE.

If there is somthing wrong in my code, please let me know exactly how to fix it.

​Please help me.

thank you.

Son, Dong-Seong
Associate III

in stm32wlxx_hal_subghz.c file, there is the function as blow

HAL_StatusTypeDef HAL_SUBGHZ_ExecSetCmd(SUBGHZ_HandleTypeDef *hsubghz,  

SUBGHZ_RadioSetCmd_t Command,

                    uint8_t *pBuffer,

                    uint16_t Size)

In the fucntion, I commeted out LL_PWR_UnselectSUBGHZSPI_NSS();

then the program was not halt, and worked well

what is the funtion - LL_PWR_UnselectSUBGHZSPI_NSS(); ?

Is it necessary?

​I want to know why that function makes program halted.

please let me know if I can comment out that function,

or if absolutely necessary, how to make it work without stopping the program.

Please help me

Hi @Son, Dong-Seong​ 

Yes, i think timer_if.c is needed for the RF. Otherwise i guess that you won't wakeup.

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.

JLojo
Associate III

Hello,

I do have a quite similar issue...

I started my project from the end-node example (single core) and adapted it to my context; meaning that I removed the sequencer and util_timer (because I already had my own) and just make periodic calls to LmHandlerProcess as in the provided example.

Everything works find except that, from time to time, I do lose the UART communication when Lora transmissions occur.

UART is used in interrupt mode, initiated by a call to HAL_UART_Receive_IT (re-issued each time a character is received), and when LoRa processing occur the UART status is no more in the receive mode (bit b1 of HAL_UART_StateTypeDef no more set).

If I disable LoRa, UART works forever!

The workaround I've found so far is to check UART status periodically, and re-issue a HAL_UART_Receive_IT if not in the busy state. But this is not very clean, and I would like to undestand what occurs in the LoRa Firmware able to cause that.

I've not been able to identify yet anything that could explain this behavior in the LoRa stack (but it is quite heavy).

Any idea or suggestion?

Thanks

JYL

I'm facing the same problem. I'm using FreeRTOS with LoRa and UART1 of STM32WL5JCI. The UART reception works fine, until I send a LoRa message it stops receiving characters.

@JLojo  @Son, Dong-Seong  Did you manage to solve it? If you can help me, I'd appreciate it!

Hi Rick88,

Actually I did not really solve the issue but found a workaround:

I simply check periodically if the UART is still in the ready mode by calling HAL_UART_GetState and checking if bit b1 is set, if not set I call again HAL_UART_Receive_IT.

Not very clean, but actually it works and allow me to continue receive data on the UART!

regards

JYL

 

Hi @JLojo,

I did it the same way you said! So far everything works. But I'm thinking about using UART2,  I'm afraid that UART1 will stop working.

 

Thank you very much!