AnsweredAssumed Answered

STM32F767ZI Timer Interrupt

Question asked by Mehmood Nurmohamed on Oct 11, 2017
Latest reply on Oct 17, 2017 by Mehmood Nurmohamed

Hello,

 

I am having some difficulties wrapping my head around what's happening with my TIM3 interrupt.  I am creating a timer class for my application.  It needs a 1 microsecond resolution.  For some reason I can only achieve a 2 microsecond resolution.  I started with the STM32F7Cube TIM_Base example for this Nucleo board.  The system core clock is 216MHz.  I have hopefully followed the instructions for configuring the timer using the method from the MCU documentation:

 

Update_event = TIM_CLK/((PSC + 1)*(ARR + 1)*(RCR + 1))  

 

My code is as follows:

 

// Initialize TIMx peripheral as follows for a 1us tick (1MHz):
// + Period = SystemCoreClock/1000000 - 1
// + ClockDivision = 0
// + Counter direction = Up
TimHandle.Init.Period = (SystemCoreClock/TICK_RATE_HZ) - 1; // TICK_RATE_HZ = 1x10^6
TimHandle.Init.Prescaler = 0;
TimHandle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
TimHandle.Init.RepetitionCounter = 0;
TimHandle.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;

 

if (HAL_TIM_Base_Init(&TimHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}

//##-2- Start the TIM Base generation in interrupt mode ####################
if (HAL_TIM_Base_Start_IT(&TimHandle) != HAL_OK)
{
/* Starting Error */
Error_Handler();
}

 

Many thanks in advance!

Outcomes