2021-11-21 08:01 PM
Hi
I am testing STM32WL55.
I am testing UART1 of STM32WL55 by referring to SubGHz_Phy_PingPong
I can transmit data using UTIL_ADV_TRACE_Send.
I tried to receive data from terminal using UART1.
But it didnot work.
I inserted UTIL_ADV_TRACE_StartRxProcess(TRACE_RxCpltCallback); in SystemApp_Init();
TRACE_RxCpltCallback is as belows
void TRACE_RxCpltCallback(uint8_t *PData, uint16_t Size, uint8_t Error)
{
UTIL_ADV_TRACE_Send(PData, Size);
}
When data is input from the terminal, no data is returned.
When a break point is set in the TRACE_RxCpltCallback function, a break is not caught when inputting data.
When I set HAL_UART_RxCpltCallback function, a break is caught in
HAL_UART_RxCpltCallback function when inputting data
When inputting data, Should TRACE_RxCpltCallback run when data is entered? Or should HAL_UART_RxCpltCallback work?
Let me know that.
Please Let me eplain how to resolve the problem if there are other problems or not
1. SystemApp_Init() function
void SystemApp_Init(void)
{
/* USER CODE BEGIN SystemApp_Init_1 */
// Ensure that MSI is wake-up system clock
__HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_MSI);
// Initialize timer and RTC
UTIL_TIMER_Init();
// Initialize the terminal
UTIL_ADV_TRACE_Init();
UTIL_ADV_TRACE_RegisterTimeStampFunction(TimestampNow);
// Set verbose LEVEL
UTIL_ADV_TRACE_SetVerboseLevel(VERBOSE_LEVEL);
/*Init low power manager*/
UTIL_LPM_Init();
/* Disable Stand-by mode */
UTIL_LPM_SetOffMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_DISABLE);
UTIL_ADV_TRACE_Send("TEST\r\n", 6);
UTIL_ADV_TRACE_StartRxProcess(TRACE_RxCpltCallback);
/* USER CODE END SystemApp_Init_1 */
}
2. SubghzApp_Init() function
void SubghzApp_Init(void)
{
/* 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);
/*calculate random delay for synchronization*/
random_delay = (Radio.Random()) >> 22; /*10bits random e.g. from 0 to 1023 ms*/
/*fills tx buffer*/
memset(BufferTx, 0x0, MAX_APP_BUFFER_SIZE);
APP_LOG(TS_ON, VLEVEL_L, "rand=%d\n\r", random_delay);
/*starts reception*/
Radio.Rx(RX_TIMEOUT_VALUE + random_delay);
/*register task to to be run in while(1) after Radio IT*/
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_SubGHz_Phy_App_Process), UTIL_SEQ_RFU, RF_Process);
/* USER CODE END SubghzApp_Init_2 */
}
3. MX_SubGhz_Phy_Process() function
void MX_SubGHz_Phy_Process(void)
{
/* USER CODE BEGIN MX_SubGHz_Phy_Process_1 */
UTIL_SEQ_Run(UTIL_SEQ_DEFAULT);
/* USER CODE END MX_SubGHz_Phy_Process_1 */
}