cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f303 counter doesn't count

jimpapay
Associate
Posted on February 21, 2013 at 07:36

Hello all,

I have been on other forums and no-one has been able to help me so far.

I am implementing a timer in a stm32f303 microcontroller.

Below is the code that I am using to start it.

Can anyone give a suggestion on why the CNT register doesn't count?

TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;

int main ( void )            

{

   

  //Enable SYSCFG clock

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

  //Timer clock

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);

  

  //Time base configuration

  TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);

  TIM_TimeBaseStructure.TIM_Period = 9999;

  TIM_TimeBaseStructure.TIM_Prescaler = 99;

  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

  TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);

  //TIM Interrupts enable

  TIM_ITConfig(TIM4, TIM_IT_Update, ENABLE);

  TIM_Cmd(TIM4, ENABLE);

 

  while(1);

 

#stm32f303
1 REPLY 1
Posted on February 21, 2013 at 12:53

Where are you observing it not counting?

Make sure not to use a simulator, ie run on actual device, check debug target tab

Can you set up one of the channels to output via a pin, or toggle a pin in the interrupt?

Are you enabling the NVIC and handling the interrupt?
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..