AnsweredAssumed Answered

Timer interrupt incorrect result

Question asked by DAZE on Oct 13, 2014
Latest reply on Oct 13, 2014 by DAZE
Hi everyone.
I need some explain why this code generating not 1KHz TIM2 interrupt.
I have no idea why generating 2KHz in APB1 clock(30MHz) & PPRE1(0b101) & CKD(0b00).

#include "stm32f2xx.h"

void TIM2_IRQHandler()
    {
    TIM2->SR&=~1;
    GPIOA->ODR^=0x00000001;     //PA0 Toggle
    }

int main()
    {
    RCC->AHB1ENR|=0x00000001;   //PA0 Clock EN
    RCC->APB1ENR|=0x00000001;   //TIM2 Clock EN
    GPIOA->MODER|=0x00000001;   //PA0 Output
    //
    TIM2->PSC=10-1;             //Prescaler //APB1clk/Presclr/fOUT = ARR <=0xFFFF   //PPRE1 101: AHB/4=30MHz
    TIM2->ARR=3000-1;           //Period
    TIM2->EGR|=0x0001;          //Update generation
    TIM2->DIER|=0x0001;         //Update interrupt EN
    TIM2->CR1|=0x0001;          //CKD : 0 //Up Counter //Counter EN
    //
    SCB->AIRCR|=0x00000300;     //Group 7:4 //Sub None
    NVIC->IP[28]|=0xF0;         //TIM2 Global Interrupt : Position [28] //Priority group 15
    NVIC->ISER[0]|=0x10000000//TIM2 Interrupt SET //[28]>>0x05==[0]   //1<<(IRQ_CH&0x1F)
    while(1){}
    }

Outcomes