2017-12-07 01:21 AM
Hello all,
I am using STM32F030R8T6 and also using HAL libraries for programming. I am using two UARTs one as a debug UART1 to send various messages to PC and UART2 for communication with Bluetooth module (BT24LT). As theHAL_UART_RxCpltCallbackis triggered only once so I am not able to receive whole string. I am also using STM32CubeMX. I have referred
https://letanphuc.net/2015/09/stm32f0-uart-tutorial-5/
. What am I missing?I have attached usart.cwhich initializes UARTs and theHAL_UART_RxCpltCallback() is as below:
//Interrupt callback routine void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { if (huart->Instance == USART2) //BT UART { len = sprintf(Txbuffer, 'BT response: %s', BT_UART_RX); HAL_UART_Transmit_IT(&huart1, Txbuffer, len); //send to PC whatever received here HAL_UART_Receive_IT(&huart2, (uint8_t *) BT_UART_RX, 1); } }
I have usedHAL_UART_Receive_IT(&huart2, (uint8_t *) BT_UART_RX, 1); in main before loop. I am also attaching the screen shot whatever received on PC.
please guide me and correct me.
#stm32f0Solved! Go to Solution.
2017-12-07 11:12 PM
Actually I found out that HAL_UART is very slow. So it missed characters. Hence I got only <LF>. So now I solved this by using LL drivers for UART2. and IRQ is triggered correctly.
And one more point, The HAL_UART_Transmit_IT() 'messes' things so use HAL_UART_Transmit() with some delay.
Hope this will help someone like me!
2017-12-07 11:12 PM
Actually I found out that HAL_UART is very slow. So it missed characters. Hence I got only <LF>. So now I solved this by using LL drivers for UART2. and IRQ is triggered correctly.
And one more point, The HAL_UART_Transmit_IT() 'messes' things so use HAL_UART_Transmit() with some delay.
Hope this will help someone like me!