AnsweredAssumed Answered

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

Question asked by kim.seung_man on Jan 24, 2014
Latest reply on Jan 24, 2014 by kim.seung_man
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.



#include <stm32f4xx.h>
#include <stdio.h>
#include <stm32f4xx_rcc.h>
#include <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);
  }

 
}

Outcomes