AnsweredAssumed Answered

32-bit Timer issue

Question asked by wang.albert.002 on Aug 11, 2014
Latest reply on Aug 12, 2014 by wang.albert.002

Sorry guys,

I know it's a really simple question but I just don't get it...
I'm using STM32F427, we all know its TIM2 is a 32-bit timer.
This is the code I'm using to setup TIM2 as a periodic timer.

==================================================================
    TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
    uint16_t PrescalerValue;
    NVIC_InitTypeDef NVIC_InitStructure;

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

    NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);

    TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; // 84000000 * 1 = 84000000 = 84M
    TIM_TimeBaseStructure.TIM_Prescaler = 42000 - 1; // 0.5ms per count
    TIM_TimeBaseStructure.TIM_Period = (30 * 2000)-1;// 30 sec
    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
    TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);

    TIM_ClearFlag(TIM2, TIM_FLAG_Update);
    TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
    TIM_Cmd(TIM2, ENABLE);
==================================================================

My system clock is configured to 168MHz and I can get this code to generate a 30-second interrupt. (TIM_TimeBaseStructure.TIM_Period = 59999)
But if I set a value larger than 65535(16-bit) to the Period (CNT) value, the IRQ doesn't fired anymore.
Anyone knows what happend about this problem?
Thanks.

BR,
Albert

Outcomes