Skip to main content
Bvan .17
Associate
May 31, 2023 10:27 AM UTC
Question

STM32WB5MMG UART receive interrupt doesn't work

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.

This topic has been closed for replies.

2 replies

waclawek.jan
Super User
Jun 2, 2023 7:03 AM UTC

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

Bvan .17
Bvan .17Author
Associate
Jun 6, 2023 9:26 AM UTC

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.