Page 1 of 1

This is an excerpt of a code written for an STM32F407 microcontroller. Describe what you expect to see when the code run

Posted: Mon Jun 06, 2022 5:07 pm
by answerhappygod
This is an excerpt of a code written for an STM32F407
microcontroller. Describe what you expect to see when the code
runs.
static void MX_TIM2_Init(void) { ... htim2.Instance = TIM2;
htim2.Init.Prescaler = 1049; htim2.Init.CounterMode =
TIM_COUNTERMODE_UP; htim2.Init.Period = 999;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; ...
} void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
if(htim->Instance == htim2.Instance) {
HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_15); } } int main(void) {
HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_TIM2_Init();
HAL_TIM_Base_Start_IT(&htim2); while (1) { TIM2->PSC =
20999; HAL_Delay(5000); TIM2->PSC = 41999; HAL_Delay(5000); }
}