2024-04-22 05:06 AM
Hi,
MCU : STM32L010R8TX.
I have configured 2 UART peripheral in STM32.
LPUART1 for GNSS and UART2 for LTE Module Communication. Both are working on Interrupt Mode for receiving data.
Uart 2 communication is request and response based. When the LTE Module sends request STM32 will response to the system.
LPUart1 is initiated and enabled Interrupt. Currently the gnss module data is not processing. if uart rx callback is called ( HAL_UART_RxCpltCallback) it will check the uart Handler and abort Uart using HAL_UART_AbortReceive(&hlpuart1); and reinitiate aborted uart.
in HAL_UART_ErrorCallback also i am aborting and reinitiating Uart by clearing ErrorCode.
But in application am copying and processing only UART2 Received Buffer Data but not doing any process witih GNSS Uart (LPUART1) received data.
Does this cause a reboot of Mcu?
2024-04-23 02:33 PM
@nikhivv07 wrote:Does this cause a reboot of Mcu?
That would depend on your code - which you haven't shown.
2024-04-23 07:00 PM
>>Does this cause a reboot of Mcu?
Probably not by itself.
Do you have a watchdog running?
Some chance of it faulting, or getting stuck in an interrupt storm. ie enabled, but not serviced
2024-04-23 10:13 PM
Hi,
Watchdog is presently not enabled.
When assigning buffer for Receive data bytes i assigned 32bytes (_HAL_GNSS_RX_SIZE_) of unsigned char buffer as follows.
HAL_UART_Receive_IT(&hlpuart1,GNSS_Uart.RxBuff,_HAL_GNSS_RX_SIZE);
similarly i enabled receive interrupt for LTE Module communication also.
but i services only LTE module receive buffer data.
here follows my callback and error routine for reference.
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
{
if(huart == &huart2) {
HAL_UART_AbortReceive(&huart2);
if(huart->ErrorCode & HAL_UART_ERROR_PE) {
// HAL_UART_ERROR_PE (0x00000001U) Parity error
// Print_Text("STM32 UART2 ERROR PE\n\r");
__HAL_UART_CLEAR_FLAG(&huart2, UART_CLEAR_PEF);
}
if(huart->ErrorCode & HAL_UART_ERROR_NE) {
// HAL_UART_ERROR_NE (0x00000002U) Noise error
// Print_Text("STM32 UART2 ERROR NE\n\r");
__HAL_UART_CLEAR_FLAG(&huart2, UART_CLEAR_NEF);
}
if(huart->ErrorCode & HAL_UART_ERROR_FE) {
// HAL_UART_ERROR_FE (0x00000004U) /*!< Frame error
// Print_Text("STM32 UART2 ERROR FE\n\r");
__HAL_UART_CLEAR_FLAG(&huart2, HAL_UART_ERROR_FE);
}
if(huart->ErrorCode & HAL_UART_ERROR_ORE) {
// HAL_UART_ERROR_ORE (0x00000008U) /*!< Overrun error
// Print_Text("STM32 UART2 ERROR ORE\n\r");
__HAL_UART_CLEAR_FLAG(&huart2, HAL_UART_ERROR_ORE);
}
if(huart->ErrorCode & HAL_UART_ERROR_DMA) {
// HAL_UART_ERROR_DMA (0x00000010U) /*!< DMA transfer error
// Print_Text("STM32 UART2 ERROR DMA\n\r");
__HAL_UART_CLEAR_FLAG(&huart2, HAL_UART_ERROR_DMA);
}
if(huart->ErrorCode & HAL_UART_ERROR_RTO) {
// HAL_UART_ERROR_RTO (0x00000020U) /*!< Receiver Timeout error
// Print_Text("STM32 UART2 ERROR RTO\n\r");
__HAL_UART_CLEAR_FLAG(&huart2, HAL_UART_ERROR_RTO);
}
UartInitialize();
UART_Buffer_Init();
huart->ErrorCode =0;
}
if(huart == &hlpuart1) {
HAL_UART_AbortReceive(&hlpuart1);
if(huart->ErrorCode & HAL_UART_ERROR_PE) {
// HAL_UART_ERROR_PE (0x00000001U) Parity error
// Print_Text("STM32 LPUART ERROR PE\n\r");
__HAL_UART_CLEAR_FLAG(&hlpuart1, UART_CLEAR_PEF);
}
if(huart->ErrorCode & HAL_UART_ERROR_NE) {
// HAL_UART_ERROR_NE (0x00000002U) Noise error
// Print_Text("STM32 LPUART ERROR NE\n\r");
__HAL_UART_CLEAR_FLAG(&hlpuart1, UART_CLEAR_NEF);
}
if(huart->ErrorCode & HAL_UART_ERROR_FE) {
// HAL_UART_ERROR_FE (0x00000004U) /*!< Frame error
// Print_Text("STM32 LPUART ERROR FE\n\r");
__HAL_UART_CLEAR_FLAG(&hlpuart1, HAL_UART_ERROR_FE);
}
if(huart->ErrorCode & HAL_UART_ERROR_ORE) {
// HAL_UART_ERROR_ORE (0x00000008U) /*!< Overrun error
// Print_Text("STM32 LPUART ERROR ORE\n\r");
__HAL_UART_CLEAR_FLAG(&hlpuart1, HAL_UART_ERROR_ORE);
}
if(huart->ErrorCode & HAL_UART_ERROR_DMA) {
// HAL_UART_ERROR_DMA (0x00000010U) /*!< DMA transfer error
// Print_Text("STM32 LPUART ERROR DMA\n\r");
__HAL_UART_CLEAR_FLAG(&hlpuart1, HAL_UART_ERROR_DMA);
}
if(huart->ErrorCode & HAL_UART_ERROR_RTO) {
// HAL_UART_ERROR_RTO (0x00000020U) /*!< Receiver Timeout error
// Print_Text("STM32 LPUART ERROR RTO\n\r");
__HAL_UART_CLEAR_FLAG(&hlpuart1, HAL_UART_ERROR_RTO);
}
GNSS_UartInitialize();
UART_GNSS_Buffer_Init();
huart->ErrorCode =0;
}
}
/******* Init *******/
void UartInitialize(void) {
HAL_UART_Receive_IT(&huart2,UserUart.RxBuff,_HAL_BUF_RX_SIZE);
}
void UART_Buffer_Init(void)
{
UserUart.RxTail = UserUart.RxBuff; //
UserUart.buffoverflow = 0; // No Overflow
}
void GNSS_UartInitialize(void) {
HAL_UART_Receive_IT(&hlpuart1,GNSS_Uart.RxBuff,_HAL_GNSS_RX_SIZE);
}
void UART_GNSS_Buffer_Init(void)
{
GNSS_Uart.RxTail = GNSS_Uart.RxBuff; //
GNSS_Uart.buffoverflow = 0; // No Overflow
}
/********** Rx complete CallBack ******/
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if(huart == &huart2) {
HAL_UART_AbortReceive(&huart2);
UartInitialize();
UserUart.buffoverflow = 1;
return;
}
if(huart == &hlpuart1) {
HAL_UART_AbortReceive(&hlpuart1);
GNSS_UartInitialize();
GNSS_Uart.buffoverflow = 1;
return;
}
}