Question
trying to understand systick and timer at STM32L1xx
Posted on March 19, 2014 at 08:26
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 - 1Period = (TIM counter clock / timer output clock) - 1 = (32KHz / 1Hz) - 1 = 32000 -1but adjusting with scope I came up with Prescaler = 1000 - 1Period=2092 - 1to get 1 sec interrupt.Can you please clarify what am I doing wrong? what I don't understand?Thanks #mco