title: STM32 Timer Interrupts
body: <p>I am trying to use timer peripheral in STM32L073 but i have problems.
  I've generated setup code in STM32Cube and using only functions that HAL API provides. Problem is that timer interrupt occurs only once and it should occur always then it overflows. I don't know if timer is even running or my setup is wrong (which I believe it shouldn't be since I am using Cube generated code). Anyone can help? </p>
  
  <p>This is called in main before while loop</p>
  
  <pre class="lang-c prettyprint-override"><code>void MX_TIM7_Init(void){
  
  TIM_ClockConfigTypeDef sClockSourceConfig;
  TIM_MasterConfigTypeDef sMasterConfig;
  
  htim7.Instance = TIM7;
  htim7.Init.Prescaler = 00;
  htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
  htim7.Init.Period = 00;
  if (HAL_TIM_Base_Init(&amp;htim7) != HAL_OK) {
      Error_Handler();
      }
  
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  if (HAL_TIMEx_MasterConfigSynchronization(&amp;htim7, &amp;sMasterConfig) != HAL_OK){
       _Error_Handler(__FILE__, __LINE__);
      }
  
  }
  </code></pre>
  
  <p>BaseMspInit Method</p>
  
  <pre class="lang-c prettyprint-override"><code>void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle){
  
  if(tim_baseHandle-&gt;Instance==TIM7){
  /* USER CODE BEGIN TIM7_MspInit 0 */
  
  /* USER CODE END TIM7_MspInit 0 */
  /* Peripheral clock enable */
  __HAL_RCC_TIM7_CLK_ENABLE();
  
  /* TIM7 interrupt Init */
  HAL_NVIC_SetPriority(TIM7_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(TIM7_IRQn);
  /* USER CODE BEGIN TIM7_MspInit 1 */
  
  /* USER CODE END TIM7_MspInit 1 */
     }
  }
  </code></pre>
  
  <p>Then in main I call this </p>
  
  <pre class="lang-c prettyprint-override"><code>HAL_TIM_Base_Start_IT(&amp;htim7);
  </code></pre>
  
  <p>which is doing this</p>
  
  <pre class="lang-c prettyprint-override"><code>HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim){
  /* Check the parameters */
  assert_param(IS_TIM_INSTANCE(htim-&gt;Instance));
  
  /* Enable the TIM Update interrupt */
  __HAL_TIM_ENABLE_IT(htim, TIM_IT_UPDATE);
  
  /* Enable the Peripheral */
  __HAL_TIM_ENABLE(htim);
  
  /* Return function status */
  return HAL_OK;
  }
  </code></pre>
  
  <p>and my Interrupt handler calls PeriodElapsedCallback</p>
  
  <pre class="lang-c prettyprint-override"><code> void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
      HAL_GPIO_TogglePin(led_GPIO_Port, led_Pin);
      }
  </code></pre>
  
  <p>It compiles there are no errors no warning, in debugger I see this interrupt is triggered only once and then never. Looking forward for answers</p>
  
  <p>P.S. using SEGGER Embedded Studio</p>