ECE471/571 (RTOS) STM32 C Example - Timer Interrupt and Slow Clock

In STM32CubeMX

  1. Initialize all peripherals with in default mode? - yes
  2. find PB0, PB7, PB14, PC13
  3. disable Ethernet (required to reduce clock rate)
  4. disable USB_OTG_FS (required to reduce clock rate)
  5. UART3 (may have to reduce transmission speed or even disable)
  6. find TIM2 - Timer2
  7. Setup System Clock (HCLK) at 1 MHz and perypherals at 1 MHz (how low can you actually go?)

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 to start the timer and enable timer interrupt
      HAL_TIM_Base_Start_IT(&htim2);
    
  7. Open source/stm32f7xx_it.c
  8. Locate void TIM2_IRQHandler() function
  9. Insert your code ** HERE1 ** and ** HERE2 **
      /* 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 ** HERE **
      HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
    

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