AnsweredAssumed Answered

Using SysTick Timer as normal timer

Question asked by berger.patrick on Jul 26, 2013
Latest reply on Jul 29, 2013 by waclawek.jan
Hi all

I've a question: How does I have to configure the systick timer to operate without interrupts and so I can check the count value...

I've tried this, but if I check if SysTick-VAL < 480 or < 48000 is the same. The pin toggels with ~360ns
01.int main(void)
02.{
03.    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
04.    GPIO_InitTypeDef GPIO_InitStructure;
05.          
06.    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
07.    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
08.    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
09.    GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;
10.    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
11.    GPIO_Init(GPIOB, &GPIO_InitStructure);    
12.  
13.    SysTick->LOAD = 0xFFFFFF;                                                                   /// -> Max
14.    SysTick->VAL = 0;
15.    SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;                       /// Enable timer
16.      
17.    while(1){
18.        SysTick->VAL = 0;
19.        while(SysTick->VAL < 48000);
20.        GPIOB->ODR ^= GPIO_Pin_2;
21.    }
22.    return 0;
23.}

Best regards
P51D

Outcomes