#21ic问答#
初始化按照主频为48M进行配置但还是匹配不上这是什么问题
//Pre = 49-4.8k 99-2.4k 199-1.2k
void TIM8_init(uint16_t Per)
{
TIM_TimeBaseInitType TIM_TimeBaseStructure;
NVIC_InitType NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = TIM8_BRK_UP_TRG_COM_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_TIM8, ENABLE);
TIM_DeInit(TIM8);
TIM_TimeBaseStructure.Prescaler = 0;//99;//分480k
TIM_TimeBaseStructure.Period = Per;//49//重到4.8k
TIM_TimeBaseStructure.ClkDiv = 0;
TIM_TimeBaseStructure.CntMode = TIM_CNT_MODE_UP;
TIM_InitTimeBase(TIM8, &TIM_TimeBaseStructure);
TIM_ConfigPrescaler(TIM8, 99, TIM_PSC_RELOAD_MODE_IMMEDIATE);
TIM_ConfigInt(TIM8, TIM_INT_UPDATE, ENABLE);
TIM_Enable(TIM8, ENABLE);//ENABLE DISABLE
} |