2016-07-25 02:20 PM
Hello, trying to generate 1 millisecond interrupt using TIM4 timer with in STM32F103 series of processor. By selectinghtim4.Init.Period = 1 able to generate Two millisecond interrupt. When we configurehtim4.Init.Period = 0, not able to get any interrupt.
Here is the Init Code for TIM4:void MX_TIM4_Init(void)
{
TIM_ClockConfigTypeDef sClockSourceConfig;
TIM_MasterConfigTypeDef sMasterConfig;
htim4.Instance = TIM4;
htim4.Init.Prescaler = 48000;
htim4.Init.CounterMode = TIM_COUNTERMODE_DOWN;
htim4.Init.Period = 0; //9;
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
HAL_TIM_Base_Init(&htim4);
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
HAL_TIM_ConfigClockSource(&htim4, &sClockSourceConfig);
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig);
}
Attached Clock configuration mxcube application in jpeg format.
Appreciate any help on this. Regards, Jim #- #stm32-timer #!stm32f1032016-07-25 03:34 PM
The values programmed as N-1
The value in prescaler should generally be the smaller of the two terms.The Period=0 turns OFF the timer, it has nowhere to countFor 1ms from a 36 MHz sourcePrescaler = 0Period = 36000 - 1For 1ms from a 48 MHz sourcePrescaler = 0Period = 48000 - 1or more nominallyPrescaler = 0;Period = (TIMCLK / 1000) - 1; // 1 KHz (1ms)