NOT TRUE! - Eclipse Complaints: undefined reference to `TIM_TimeBaseInit'
Hi All,
SW4STM32 complaints about undefined references but it’s not true. Everything is there for the compiler to find via #include “stm32f10x.h”. I added #include “stm32f10x_tim.h” but that’s not even necessary because in #include “stm32f10x.h” other declarations lead to the appropriate peripheral library headers files. I have checked this thoroughly with stm32f10x_stdperiph_lib_um.chm reference manual. Screenshot of SW4STM32 view attached.
void InitializeLEDs(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
GPIO_InitTypeDef gpioStructure;
gpioStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13;
gpioStructure.GPIO_Mode = GPIO_Mode_Out_PP;
gpioStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &gpioStructure);
GPIO_WriteBit(GPIOD, GPIO_Pin_12 | GPIO_Pin_13, Bit_RESET);
}
void InitializeTimer(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_TimeBaseStructure.TIM_Prescaler = 40000;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = 500;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_Cmd(TIM2, ENABLE);
}
int main()
{
InitializeLEDs();
InitializeTimer();
for (;;)
{
int timerValue = TIM_GetCounter(TIM2);
if (timerValue == 400)
GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_SET);
else if (timerValue == 500)
GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_RESET);
}
}