cancel
Showing results for 
Search instead for 
Did you mean: 

No Interrupts at all reveived on STM32F413

JHeni
Associate II

Hey guys

I'm currently wondering why i'm not reveiving any interrupts at all on my STM32F413

I used cube mx to create a new project.

For starters I'd like to send some data via UART with an interupt transfer.

uint8_t dummy[4] = { 0 };
volatile HAL_StatusTypeDef hal_uart_transmit = HAL_UART_Transmit_IT(&huart1, dummy, 4);
 
HAL_Delay(5000);

I'm only transfering 4 byte. That should be possible within 5 Seconds =)

the hal_uart_transmit status tells me OK. But this does not say anything about the actual transfer status since it is an interrupt transfer.

My Expectation: I'd expect some sort of UART1 interrupt (doens't matter if TX complete, RXNE or error at the moment).

Therefore i set a breakpoint in the UART 1 IRQ Handler BEFORE calling HAL_UART_IRQHandler(&huart1);

But i'm never getting there. So there is something wrong with my interrupts.

I verified that MX_USART1_UART_Init() is called at the beginning of main()

void MX_USART1_UART_Init(void)
{
 
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 115200;
  huart1.Init.WordLength = UART_WORDLENGTH_9B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_EVEN;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
 
  if (HAL_UART_Init(&huart1) != HAL_OK)
  {
    Error_Handler();
  }
 
}

MX_UART1_Init calls the MSP Init which looks like this

void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
{
 
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  if(uartHandle->Instance==USART1)
  {
  /* USER CODE BEGIN USART1_MspInit 0 */
 
  /* USER CODE END USART1_MspInit 0 */
    /* USART1 clock enable */
    __HAL_RCC_USART1_CLK_ENABLE();
  
    __HAL_RCC_GPIOA_CLK_ENABLE();
    /**USART1 GPIO Configuration    
    PA9     ------> USART1_TX
    PA10     ------> USART1_RX 
    */
    GPIO_InitStruct.Pin = UCE_USART1_TX_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
    HAL_GPIO_Init(UCE_USART1_TX_GPIO_Port, &GPIO_InitStruct);
 
    GPIO_InitStruct.Pin = UCE_USART1_RX_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
    HAL_GPIO_Init(UCE_USART1_RX_GPIO_Port, &GPIO_InitStruct);
 
    /* USART1 interrupt Init */
    HAL_NVIC_SetPriority(USART1_IRQn, 7, 0);
    HAL_NVIC_EnableIRQ(USART1_IRQn);
  /* USER CODE BEGIN USART1_MspInit 1 */
 
  /* USER CODE END USART1_MspInit 1 */
  }
}

So the UART Interrupt should be enabled.

Do you have any ideas, why the interrupts are not comming through?

My UART Tests runs as a first step, before anything else runs. Nobody could disable my UART interrupt

0 REPLIES 0