AnsweredAssumed Answered

trying to understand systick and timer at STM32L1xx

Question asked by rogel.zohar on Mar 19, 2014
Latest reply on Mar 22, 2014 by Clive One
Hello,

I'm using STM32L152 discovery board.
I'm trying to define systick for 100mSec, and tim2 to 1 sec.
After measuring the pin togeling with scope, this is what I came up with:

I know SystemCoreClock is 32MHz.

For systick using 100mSec interrupt,
I tried using SysTick_Config(SystemCoreClock / 100) to get 100mSec,
but adjusting with scope I ended with
SysTick_Config(SystemCoreClock / 153) to get accurate 100mSec.

For tim2 at 1 sec interrupt, I tried using:
Prescaler = (TIM_CLK / TIM counter clock) - 1 = 32MHz / 32KHz - 1= 1000 - 1
Period = (TIM counter clock / timer output clock) - 1 = (32KHz / 1Hz) - 1 = 32000 -1
but adjusting with scope I came up with 
Prescaler = 1000 - 1
Period=2092 - 1
to get 1 sec interrupt.

Can you please clarify what am I doing wrong? what I don't understand?

Thanks

Outcomes