2009-06-22 04:09 AM
TIM1 'undeclared' (first use...)
2011-05-17 04:15 AM
Hi,
I'm starting with Ride7. I want To set a Counter (Timer1), and few operation after, To read the value of this counter. Normaly easy. But when i build the code:Code:
u16 TIMCounter = 0xFFFF;
TIM_SetCounter(TIM1, TIMCounter);the Build is failed: TIM1 'undeclared' (first use in founction) but i put #include I don't understand, normaly i should see the value 0xFFFF in CNT register of timer 1. No ? Thank you, Jean-Claude Védy2011-05-17 04:15 AM
Ok, thank you, i hadn't see comments before each declaration in stm***.conf
I will ask better questions now.2011-05-17 04:15 AM
you must first include the library.
Something like : #include ''stm32f10x_lib.h'' Then you declare the structure to initialize your timer with: TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; Fill in the structure: TIM_TimeBaseStructure.TIM_Period = 2; TIM_TimeBaseStructure.TIM_Prescaler = 0; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; And initialize the Timer: TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); Alternatively you may write the registers direclty and not use the provided library. TIM3->REGx = 0x????????; Check some of the examples included with the library. This should help you.2011-05-17 04:15 AM
At least with the version of the fwlib I use (2.0), you also need to uncomment ''#define _TIM'' and ''#define _TIM1'' in stm32f10x_conf.h