如何在RTOS中为stm32f746NG_Discovery在TIM_BASE中配置TIMER?

vmpqdwk3  于 2023-05-16  发布在  其他
关注(0)|答案(1)|浏览(93)

我想使用stm32f746NG_Discovery板的timer8,但不知道如何配置。谁有简单的keil代码?

6vl6ewon

6vl6ewon1#

tim8配置更新中断

__HAL_RCC_TIM8_CLK_ENABLE();

TIM8 -> PSC = 999;
TIM8 -> ARR = SystemCoreClock / ((TIM8 -> PSC + 1) * freq) - 1;
TIM8 -> EGR |= TIM_EGR_UG;
if(TIM8 -> SR & TIM_SR_UIF) TIM8 -> SR = ~(TIM_SR_UIF);
TIM8 -> DIER |= TIM_DIER_UIE;
TIM8 -> CR1 = TIM_CR1_CEN;

NVIC_EnableIRQ(TIM8_TRG_COM_TIM14_IRQn);

相关问题