cancel
Showing results for 
Search instead for 
Did you mean: 

IAR error ''SysTick_IRQn'' has already been declared in the current scope.

to_sam_kim
Associate II
Posted on January 24, 2014 at 17:56

Hello,

I try to write a simple LED blink with delay by SisTick.

But, IAR EWARM keep giving me error, ''SysTick_IRQn'' has already been declared in the current scope'', with SysTick ISR.

So I clicked the error message. It leaded me to the line below in stm32f4xx.h.

SysTick_IRQn                = -1,     /*!< 15 Cortex-M4 System Tick Interrupt

I tested a similar code with Keil. Keil didn't give the error.

Please let me know any mistakes.

Thanks.

&sharpinclude <stm32f4xx.h>

&sharpinclude <stdio.h>

&sharpinclude <stm32f4xx_rcc.h>

&sharpinclude <stm32f4xx_gpio.h>

void GPIO_Configuration(void)

{

  GPIO_InitTypeDef GPIO_InitStruct;

 

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

 

  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;

  GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;

  GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;

  GPIO_Init(GPIOD, &GPIO_InitStruct);

}

volatile unsigned int msTicks;

void SysTick_IRQn(void)

{

   msTicks++;

}

void Delay (unsigned int dlyTicks)

{                                             

  unsigned int curTicks;

  curTicks = msTicks;

  while ((msTicks - curTicks) < dlyTicks);

}

void main(void)

{

  GPIO_Configuration();

 

  /* max para should be 2^24-1 = 16777215 = 0xFFFFFF, Systic clock = HCLK = 168MHz. */

  /* ms tick. */

  SysTick_Config(SystemCoreClock / 1000); 

  

  while(1)

  {

   GPIO_SetBits(GPIOD, GPIO_Pin_12);    // LED4, Green on

   GPIO_ResetBits(GPIOD, GPIO_Pin_13);

   GPIO_ResetBits(GPIOD, GPIO_Pin_14);

   GPIO_ResetBits(GPIOD, GPIO_Pin_15);

  

   Delay(50);

     

   GPIO_ResetBits(GPIOD, GPIO_Pin_12);

   GPIO_SetBits(GPIOD, GPIO_Pin_13);    // LED5, Orange on

   GPIO_ResetBits(GPIOD, GPIO_Pin_14);

   GPIO_ResetBits(GPIOD, GPIO_Pin_15);

  

   Delay(50);

  

   GPIO_ResetBits(GPIOD, GPIO_Pin_12);

   GPIO_SetBits(GPIOD, GPIO_Pin_14);    // LED5, red on

   GPIO_ResetBits(GPIOD, GPIO_Pin_13);

   GPIO_ResetBits(GPIOD, GPIO_Pin_15);

  

   Delay(50);

  

   GPIO_ResetBits(GPIOD, GPIO_Pin_12);

   GPIO_SetBits(GPIOD, GPIO_Pin_15);    // LED5, red on

   GPIO_ResetBits(GPIOD, GPIO_Pin_14);

   GPIO_ResetBits(GPIOD, GPIO_Pin_13);

  

  

   Delay(50);

  }

 

}

#stm32f4-discovery-sistick
3 REPLIES 3
Posted on January 24, 2014 at 18:36

void SysTick_IRQn(void)

{

   msTicks++;

}

No this should be SysTick_Handler(void) it's a function, not an index into the NVIC/SystemHandler table.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chen
Associate II
Posted on January 24, 2014 at 18:41

Hi

There must be another define somewhere.

Or the file stm32f4xx.h has been included twice in a file somewhere.

Another possibility is the file stm32f4xx.h has been added twice in the IAR project settings.

to_sam_kim
Associate II
Posted on January 24, 2014 at 19:28

Thank you so much!

I confused SysTick_Handler with SysTick_IRQn. I used SysTick_Handler in Keil that's why I didn't get error.

Problem was solved. Thanks again.