Skip to main content
MAkke
Associate III
January 17, 2020
Question

EXTI_InitTypeDef and NVIC_InitTypeDef not recognized.

  • January 17, 2020
  • 2 replies
  • 1766 views

I set up several pins as EXTI in the CubeMX configurator, but STM32CubeIDE doesn't recognize the EXTI_InitTypeDef and NVIC_InitTypeDef datatypes. Based on the configuration I would expect the correct libraries to be included, but when compiling I get the error "unknown type name".

I get the error when I use the following code, which was originally written for some STM32F4, then adjusted for application on the STM32F303CC.

void Configure_PA3(void) {

   /* Set variables used */

   GPIO_InitTypeDef GPIO_InitStruct;

   EXTI_InitTypeDef EXTI_InitStruct; // <-

   NVIC_InitTypeDef NVIC_InitStruct; // <-

   /* Enable clock for GPIOA */

   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

   /* Enable clock for SYSCFG */

   RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

   /* Set pin as input */

   GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;

   GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;

   GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;

   GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;

   GPIO_InitStruct.GPIO_Speed = GPIO_Speed_72MHz;

   GPIO_Init(GPIOB, &GPIO_InitStruct);

   /* Tell system that you will use PB12 for EXTI_Line12 */

   SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource3);

   /* PA3 is connected to EXTI_Line3 */

   EXTI_InitStruct.EXTI_Line = EXTI_Line3;

   /* Enable interrupt */

   EXTI_InitStruct.EXTI_LineCmd = ENABLE;

   /* Interrupt mode */

   EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;

   /* Triggers on rising and falling edge */

   EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;

   /* Add to EXTI */

   EXTI_Init(&EXTI_InitStruct);

   /* Add IRQ vector to NVIC */

   /* PA3 is connected to EXTI_Line3, which has EXTI3_IRQn vector */

   NVIC_InitStruct.NVIC_IRQChannel = EXTI3_IRQn;

   /* Set priority */

   NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0x00;

   /* Set sub priority */

   NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0x01;

   /* Enable interrupt */

   NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;

   /* Add to NVIC */

   NVIC_Init(&NVIC_InitStruct);

}

void EXTI3_IRQHandler(void) {

   /* Make sure that interrupt flag is set */

   if (EXTI_GetITStatus(EXTI_Line3) != RESET) {

       /* Do your stuff when PA3 is changed */

      HAL_GPIO_TogglePin(GPIOB,GPIO_PIN_11);

       /* Clear interrupt flag */

       EXTI_ClearITPendingBit(EXTI_Line3);

   }

}

This topic has been closed for replies.

2 replies

dbgarasiya
Senior
January 25, 2020

you are missng inerrupt related file and not set path

MAkke
MAkkeAuthor
Associate III
January 27, 2020

It must be something like that all right. But how can it be missing? I did the setup through the GUI, so you'd think it would include all the necessary libraries. I do have an stm32f3xx_it.h and stm32f3xx_it.c, so which file are you referring to? How do I set the path?