0
\$\begingroup\$

I program STM32F4 using External Interrupt, and there is an error below:

enter image description here

Error[Li005]: no definition for "SYSCFG_EXTILineConfig" referenced from C:\Users\AnhDoan\Desktop\STM32\IAR[GPIO LED_Blink_Freq_Button\Debug\Obj\main.o]

Error while running Linker.

Code:

>     /* Traffic Light: LED13 for 10s, then LED14 for 5s, then LED15 for 10s Press the button: switch to the next LED immediately (order:
> LED13->14, LED14->LED14, LED15->LED13) Avoid pressing too fast
> */
> 
> #include "stm32f4xx.h"
> 
> 
> GPIO_InitTypeDef  GPIO_InitStructure; TIM_TimeBaseInitTypeDef 
> TIM_BaseStruct; EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef
> NVIC_InitStructure;
> 
> void GPIO_Configuration(void); void TIM_Configuration(void); void
> EXTI_Configuration(void);
> 
> int main(void) {   GPIO_Configuration();   EXTI_Configuration();  
> TIM_Configuration();   while(1)   {   } }
> 
> 
> void GPIO_Configuration(void) {  
> RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);  
> GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;  
> GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;  
> GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;  
> GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;  
> GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;   GPIO_Init(GPIOD,
> &GPIO_InitStructure); }
> 
> void EXTI_Configuration() {  
> RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);  
> RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
>      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;  
> GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;  
> GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;  
> GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;  
> GPIO_Init(GPIOA,&GPIO_InitStructure);
>      SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);
>      EXTI_InitStructure.EXTI_Line = EXTI_Line0;   EXTI_InitStructure.EXTI_LineCmd = ENABLE;  
> EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;  
> EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;  
> EXTI_Init(&EXTI_InitStructure);
>      //Add Interrupt (IRQ) to NVIC   NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;  
> NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;  
> NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;  
> NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;  
> NVIC_Init(&NVIC_InitStructure); }
> 
> void TIM_Configuration(void) {  
> RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
>      TIM_BaseStruct.TIM_Prescaler = 21000-1;               //0.5s   TIM_BaseStruct.TIM_CounterMode = TIM_CounterMode_Up;  
> TIM_BaseStruct.TIM_Period = 2000-1;   TIM_BaseStruct.TIM_ClockDivision
> = 0;   TIM_BaseStruct.TIM_RepetitionCounter = 0;
>      TIM_TimeBaseInit(TIM2,&TIM_BaseStruct);
>      TIM_Cmd(TIM2,ENABLE);
>      NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;  
> NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;  
> NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;  
> NVIC_Init(&NVIC_InitStructure); }
> 
> 
> 
> #ifdef  USE_FULL_ASSERT void assert_failed(uint8_t* file, uint32_t line) {    /* User can add his own implementation to report the file
> name and line number,
>      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
> 
>   /* Infinite loop */   while (1)   {   } }
> #endif

Can you please tell me what is the problem and how to fix it (in detail) please. I checked but cannot find any error in the code.

Thank you so much.

\$\endgroup\$
  • \$\begingroup\$ It's a link error saying the symbol SYSCFG_EXTILineConfig doesn't exist. What does EXTI_Configuration contain? \$\endgroup\$ – Colin Mar 13 '17 at 23:55
  • \$\begingroup\$ If you post your code here, rather than a screenshot of some of it you'll get more help. \$\endgroup\$ – Colin Mar 14 '17 at 8:29
  • \$\begingroup\$ @Colin__s I have already added the code. Can you give me some more details? There is a definition of SYSCFG_EXTILineConfig in .h file, so why there is this error? \$\endgroup\$ – Nguyễn Thanh Vũ Mar 14 '17 at 19:13
  • \$\begingroup\$ Do you have USE_STDPERIPH_DRIVER defined in your project so the Standard Peripherals Library .h files are included (end of stm32f4xx.h inclusion of "stm32f4xx_conf.h")? Have you included the SPL in your project (or at least stm32f4xx_syscfg.c)? \$\endgroup\$ – Tut Mar 14 '17 at 19:36
1
\$\begingroup\$

The linker is looking for the function SYSCFG_EXTILineConfig() but can't find it, probably because the source file is missing from your workspace. The missing file is probably named something like stm32f4xx_syscfg.c

BTW, the "definition of SYSCFG_EXTILineConfig in .h file" is a declaration (prototype), not a definition.

\$\endgroup\$
  • \$\begingroup\$ stm32f4xx_syscfg.c may be found in the src directory of the Standard Peripherals Library, and yes SYSCFG_EXTILineConfig() is defined in that file. \$\endgroup\$ – Tut Mar 14 '17 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.