I am using a STM32L07x8 chip and the HAL driver from stcube. I cannot make a uart work in interrupt mode in any way. In blocking mode it works fine. I tried stuff like
__HAL_UART_ENABLE_IT(&UartHandle_RADIO, UART_IT_RXNE);
HAL_NVIC_SetPriority(USART1_IRQn, 0, 2);
HAL_NVIC_EnableIRQ(USART1_IRQn);
before or after i enable the UART. The USART1_IRQHandler() function or the HAL_UART_RxCpltCallback is never called. The RXNE bite in CR1 is enabled. I just want my program to wait untill it receives a bite in the UART. I tried calling
HAL_UART_Receive_IT(&UartHandle, (uint8_t *) rxBuffer, 1);
Before a main loop, during the main loop, still nothing. I do not understand at all how this HAL works. All the examples i find do nothing. I just need my program to wait for a few specific characters to come via UART, do a few steps after, then go back to waiting for those characters again.
__HAL_RCC_USART1_CLK_ENABLE();
UartHandle_RADIO.Instance = USART1;
UartHandle_RADIO.Init.BaudRate = 115200; // 9600;
UartHandle_RADIO.Init.WordLength = USART_WORDLENGTH_8B;
UartHandle_RADIO.Init.StopBits = USART_STOPBITS_1;
UartHandle_RADIO.Init.Parity = USART_PARITY_NONE;
UartHandle_RADIO.Init.Mode = USART_MODE_TX_RX;
// __HAL_UART_ENABLE_IT(&UartHandle_RADIO, UART_IT_RXNE);
HAL_NVIC_SetPriority(USART1_IRQn, 0, 2);
HAL_NVIC_EnableIRQ(USART1_IRQn);
if (HAL_UART_DeInit(&UartHandle_RADIO) != HAL_OK) {
Error_Handler();
}
if (HAL_UART_Init(&UartHandle_RADIO) != HAL_OK) {
Error_Handler();
}