AnsweredAssumed Answered

UART4 IRQ Handler not firing

Question asked by apothus on Sep 20, 2014
Latest reply on Sep 21, 2014 by apothus
With my STM32F4 discovery board I cannot get the UART4_IRQHandler to be triggered on incoming serial data. However the USART2_IRQHandler functions as expected and when the data is ready from the UART4 RX data registered and transmitted out it works without a problem, only the interrupt will not work.

Initialisation
++++++++++++++++++++
void uartLink_init(void){
  USART_InitTypeDef USART_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;
  NVIC_InitTypeDef NVIC_InitStructure;


     RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);
     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
     
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
       GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
       GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
       GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
       GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
       GPIO_Init(GPIOC, &GPIO_InitStructure);
     GPIO_SetBits(GPIOC, GPIO_Pin_9);
     
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_USART6);
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_UART4);


  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_11;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
     
  USART_InitStructure.USART_BaudRate = 115200;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
       USART_InitStructure.USART_Parity = USART_Parity_No;
       USART_InitStructure.USART_HardwareFlowControl =      USART_HardwareFlowControl_None;
       USART_InitStructure.USART_Mode = USART_Mode_Rx;
     
       /* USART Rx configuration */
       USART_Init(UART4, &USART_InitStructure);
         /* USART Tx configuration */
       USART_InitStructure.USART_Mode = USART_Mode_Tx;
     USART_Init(USART6, &USART_InitStructure);


     NVIC_InitStructure.NVIC_IRQChannel = UART4_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
     
  /* Enable USART */
  USART_Cmd(UART4, ENABLE);
  USART_Cmd(USART6, ENABLE);
     
     messageStatus = fingerDataWait;
}

+++++++++++++++++++++++++++++
Interrupt
+++++++++++++++++++++++++++++
void UART4_IRQHandler(void){
     uint8_t data = USART_ReceiveData(UART4);
     
     USART_SendData(USART6, data);
}

+++++++++++++++++++++++++
Main loop
+++++++++++++++++++++++++
int main(void)
{
     prvSetupHardware();
     uartLink_init();
     power_GPS(POWER_ON);
     gps_init();
    
   while(1)                                
   {
     if (USART_GetFlagStatus(UART4, USART_FLAG_RXNE) != RESET)
     {
       uint16_t x = USART_ReceiveData(UART4);
  
       while(USART_GetFlagStatus(USART6, USART_FLAG_TXE) == RESET);
  
       USART_SendData(USART6, x);
     }
   }
++++++++++++++++++++++++

Interestingly with the GPS unit powered and configured as a serial with an interrupt it does not retrun to the main loop when in the debug state. However On the main application which has a freeRTOS implementation it works without problem. This information is possible inconsiquential to the uart4 fault i am having

Outcomes