cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB5MMG UART receive interrupt doesn't work

Bvan .17
Associate

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.

2 REPLIES 2

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
Associate

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.