STM32 UART Call back function
Hi,
I am using STM32F4 based microcontroller and configured it using STM32Cube IDE and free rtos.
I have my uart driver interrupt for reception with call back function.
HAL_UART_Receive_IT(&huart2, (uint8_t *)&Uart.RxByte, 1);
and call back function HAL_UART_RxCpltCallback
Its working fine.
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_UART_Receive_IT();
}
I want to transmit the received data back using transmission interrupt using HAL_UART_TxCpltCallback function.
I have transmitted this string using a serial console . The string started with $ and ended with \r\n (0x0D,0X0A).
$GPGGA,181908.00,3404.7041778,N,07044.3966270,
W,4,13,1.00,495.144,M,29.200,M,0.10,0000*40\r\n
But, the problem I faced is, when I transmit this string it is executing in infinite loop.
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_UART_Transmit_IT();
}
int main(void)
{
//Inialization of clocks, USART, and RTOS threads.
void Default task(void)
{
for(;;)
{
}
}
void SerialTask(void)
{
for(;;)
{
if(Frameisready)
{
//sending one byte of data for triggering uart call back.
HAL_UART_Transmit_IT ();
}
}
}
void Transmit_Task(void)
{
for(;;)
{
HAL_UART_TxCpltCallback(&huart2);
}
}
After I send that $GPGGA,181908.00,3404.7041778,N,07044.3966270,
W,4,13,1.00,495.144,M,29.200,M,0.10,0000*40\r\n
I am getting infinite sentences instead of single one. How to break the HAL_UART_TxCpltCallback(&huart2); function. Kindly help me,