cancel
Showing results for 
Search instead for 
Did you mean: 

Interrupt Doesn't occur

anuj
Associate II
Posted on September 01, 2016 at 21:47

I am working on STM32F030 Discovery. I trying to generate 1ms interrupt. But the code doesn't work. But when change the htim3.Init.Period from 0 to 1, it works with 2ms interrupt. But I need 1ms interrupt. Frequency is set at 48MHz.

Here is my TIM3_Init

void TIM3_Init(void)

{

  TIM_ClockConfigTypeDef sClockSourceConfig;

  TIM_MasterConfigTypeDef sMasterConfig;

  htim3.Instance = TIM3;

  htim3.Init.Prescaler = 48000;

  htim3.Init.CounterMode = TIM_COUNTERMODE_UP;

  htim3.Init.Period = 0;

  htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

  HAL_TIM_Base_Init(&htim3);

  sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;

  HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig);

  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;

  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;

  HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig);

}

#!stm32-!cubemx #interrupts
1 REPLY 1
Posted on September 01, 2016 at 22:43

Put the smaller number in the Prescaler, review the diagrams in the Reference Manual to understand how the counting portion functions.

  htim3.Init.Prescaler = 0; // DIV1

  htim3.Init.CounterMode = TIM_COUNTERMODE_UP;

  htim3.Init.Period = 48000-1; // DIV48000, ie 0-47999, where final count before rollover is 47999

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..