ECE471/571 (RTOS) STM32 C Example - Timer Interrupt (frequency controlled)

In STM32CubeMX

  1. Initialize all peripherals with in default mode? - yes
  2. find PB0, PB7, PB14, PC13
  3. find TIM2 - Timer2
  4. disable Ethernet (optional)
  5. disable USB_OTG_FS (optional)

Adapt and compile a project (example 1)

  1. Open source/main.c
  2. Locate int main() function
  3. Inspect the GPIO initialization called from main()
  4. Locate the timer initialization in main()
  5. Insert your code ** HERE **
      MX_TIM2_Init();
      /* USER CODE BEGIN 2 */
          ** HERE **
      /* USER CODE END 2 */
    
  6. Code for starting the timer and enabling timer interrupt
      HAL_TIM_Base_Start_IT(&htim2);
    
  7. Open source/stm32f7xx_it.c
  8. Locate void TIM2_IRQHandler() function
  9. Insert your code ** HERE **
      /* USER CODE BEGIN TIM2_IRQn 0 */
          ** HERE **
      /* USER CODE END TIM2_IRQn 0 */
      HAL_TIM_IRQHandler(&htim2);
      /* USER CODE BEGIN TIM2_IRQn 1 */
    
      /* USER CODE END TIM2_IRQn 1 */
    
  10. Code for toggling the green LED in order to demonstrate that the timer interrupt is triggered
        HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
    

web site front local main page local list page general bookmarks software bookmarks go back copyright info