AnsweredAssumed Answered

High frequency timer interrupt issue, STM32F429

Question asked by marechal.alexandre on Mar 11, 2014
Latest reply on Mar 11, 2014 by waclawek.jan
Hello
I am trying to configure a timer to get interruption at 12 MHz on the STM32F429 Discovery Kit.
I am currently using TIM2 and I cannot reach more than 2.25 MHz
Theoritically I could reach 45MHz right?
Thank you for helping me.



#include <stm32f4xx_gpio.h>
#include <stm32f4xx_tim.h>
#include <stm32f4xx_rcc.h>
#include <misc.h>


void InitializeTimer()
{
          TIM_TimeBaseInitTypeDef timerInitStructure;
     
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);


   
    timerInitStructure.TIM_Prescaler = 1;
    timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
    timerInitStructure.TIM_Period = 1;
    timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
    timerInitStructure.TIM_RepetitionCounter = 0;
    TIM_TimeBaseInit(TIM2, &timerInitStructure);
    TIM_Cmd(TIM2, ENABLE);
          TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
}


void EnableTimerInterrupt()
{
    NVIC_InitTypeDef nvicStructure;
    nvicStructure.NVIC_IRQChannel = TIM2_IRQn;
    nvicStructure.NVIC_IRQChannelPreemptionPriority = 0;
    nvicStructure.NVIC_IRQChannelSubPriority = 1;
    nvicStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&nvicStructure);
}


void GPIO_Configuration(void) {
     GPIO_InitTypeDef GPIO_InitStructure;
     
     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
     
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
}


void TIM2_IRQHandler(void)
{


          if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET){
               TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
      GPIO_ToggleBits(GPIOC, GPIO_Pin_8);
    }
}




/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
     GPIO_Configuration();
  InitializeTimer();
     EnableTimerInterrupt();
  while (1)
  {
     
     }
}




Outcomes