UART communication works only in debug mode
Hi,
I hope this is the right topic to ask this question.
I'm new to embedded, and I'm experimenting with stm32l496ag discovery and sending/receiving uart form the connected pc using interrupts.
I configured USART2 in CubeMX, enabling "global interrupt" in NVIC Settings tab, and setting the baud rate to 9600.
I'm using GPIO "PA2" and "PD6".
My problem is that while in debugging, HAL_UART_RxCpltCallback is called and acts as expected, sending back the "Test123" message seen below.
On the other hand, when running without debugging I get no message back.
I tried setting a LED on when receiving, which as well works in debug but not outside of it.
What could cause this? I'm at a loss.
Any help would be appreciated!
These are the relevant code snippets (to my limited knowledge, I'll happily supply more):
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_CRC_Init();
MX_I2C2_Init();
MX_DMA2D_Init();
MX_QUADSPI_Init();
MX_FMC_Init();
MX_UART4_Init();
MX_USART2_UART_Init();
MX_TouchGFX_Init();
/* USER CODE BEGIN 2 */
HAL_UART_Receive_IT(&huart2, (uint8_t*) rx_buff , 10);
HAL_UART_Transmit_IT(&huart2, (uint8_t*) tx_buff , 10); /* Initialize all configured peripherals */
MX_GPIO_Init();
MX_CRC_Init();
MX_I2C2_Init();
MX_DMA2D_Init();
MX_QUADSPI_Init();
MX_FMC_Init();
MX_UART4_Init();
MX_USART2_UART_Init();
MX_TouchGFX_Init();
/* USER CODE BEGIN 2 */
HAL_UART_Receive_IT(&huart2, (uint8_t*) rx_buff , 10);
HAL_UART_Transmit_IT(&huart2, (uint8_t*) tx_buff , 10);/* USER CODE BEGIN 4 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){
__HAL_UART_CLEAR_OREFLAG(&huart2);
HAL_UART_Transmit(&huart2, (uint8_t *) "TEST123", sizeof("TEST123"), 1000);
HAL_UART_Receive_IT(&huart2, (uint8_t*) rx_buff , 10);
}