AnsweredAssumed Answered

Timer 5 Setup

Question asked by parker.clinton on May 28, 2013
Latest reply on May 28, 2013 by Clive One
I'm just stering with the STM324f Discovery board and am trying to get timer 5 setup as a free running 1us timer that I can access in my code for timing. No matter what I do, I can't get TIM5->CNT to change from zero. Any idea what I'm doing wrong? Here's the relevent code in main():

/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */

 

#define PLL_M 8
#define PLL_N 336
/* SYSCLK = PLL_VCO / PLL_P */
#define PLL_P 2
/* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */
#define PLL_Q 7

int main()
{
 
SystemInit();
  TIM5->
CR1 = 0; // disable timer 5
  TIM5->DIER = 0; // no interrupts
  TIM5->CNT = 0; // reset timer value
  TIM5->PSC = (PLL_N / PLL_P) - 1; // prescaler
  TIM5->ARR = 0xFFFFFFFF; // reload value
  TIM5->EGR = 1;
TIM5->
CR1 = TIM_CR1_CEN; // enable timer 5
RCC->APB1ENR |= RCC_APB1ENR_TIM5EN;
TIM5->
SR = 0; // reset flags

 

Outcomes