cancel
Showing results for 
Search instead for 
Did you mean: 

TIM1 'undeclared' (first use...)

jean-claude
Associate II
Posted on June 22, 2009 at 13:09

TIM1 'undeclared' (first use...)

4 REPLIES 4
jean-claude
Associate II
Posted on May 17, 2011 at 13:15

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édy

jean-claude
Associate II
Posted on May 17, 2011 at 13:15

Ok, thank you, i hadn't see comments before each declaration in stm***.conf

I will ask better questions now.

robinsm
Associate II
Posted on May 17, 2011 at 13:15

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.

miles
Associate II
Posted on May 17, 2011 at 13:15

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