2023-05-31 03:27 AM
I'm using a STM32WB5MMG chip and I'm trying to receive data with the HAL_UART_Receive_IT() function. But for some reason the HAL_UART_RxCpltCallback function never gets called. Receiving data with blocking mode works, but with an interrupt it doesn't want to work
I have enabled the global interrrupt of the USART with CubeMX and I still see that the box is checked.
The code I have written should wait until it receives 4 bytes, then echo those bytes back and start waiting again.
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_UART_Transmit(&huart1, rxBuffer, 4, 100);
HAL_UART_Receive_IT(&huart1, rxBuffer, 4);
}
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* Configure the peripherals common clocks */
PeriphCommonClock_Config();
/* IPCC initialisation */
MX_IPCC_Init();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_I2C1_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
int error = HAL_UART_Receive_IT(&huart1, rxBuffer, 4);
if(error != HAL_OK){
while(1);
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
}
}
I'm not really experienced with stm32 chips and CubeIDE, so I don't know if I have forgotten something.
2023-06-02 12:03 AM
Read out and check the UART registers content in debugger. Do you see RXNE bit being set and data arriving in the receive-data register? Is the interrupt enabled at UART level? Here are some generic steps to debug "interrupt does not fire" problems.
JW
2023-06-06 02:26 AM
There wasn't any data arriving in the receiver-data register and it didn't look like the RXNE bit was being set.
But I managed to fix it. Looks like I connected a boot pin that shouldn't be connected. Causing the interrupts and systick to stop working.
Thank you for helping.