STM32CubeIDE,在FreeRTOS 中 。当我将时钟周期频率修改为 100000 而不是默认的 1000 时, 文件 stm32f4xx_hal_timebase_tim.c 中生成的代码并没有发生变化。 在配置的 sys 选项卡中,将 TIM8 设置为时基源。 下边程序段有什么问题 HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) { RCC_ClkInitTypeDef clkconfig; uint32_t uwTimclock = 0; uint32_t uwPrescalerValue = 0; uint32_t pFLatency; /*Configure the TIM8 IRQ priority */ HAL_NVIC_SetPriority(TIM8_UP_TIM13_IRQn, TickPriority ,0); /* Enable the TIM8 global Interrupt */ HAL_NVIC_EnableIRQ(TIM8_UP_TIM13_IRQn); /* Enable TIM8 clock */ __HAL_RCC_TIM8_CLK_ENABLE(); /* Get clock configuration */ HAL_RCC_GetClockConfig(&clkconfig, &pFLatency); /* Compute TIM8 clock */ uwTimclock = 2*HAL_RCC_GetPCLK2Freq(); /* Compute the prescaler value to have TIM8 counter clock equal to 1MHz */ uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000) - 1); /* Initialize TIM8 */ htim8.Instance = TIM8; htim8.Init.Period = (1000000 / 1000) - 1; htim8.Init.Prescaler = uwPrescalerValue; htim8.Init.ClockDivision = 0; htim8.Init.CounterMode = TIM_COUNTERMODE_UP; ...... ...... ..... }
|