本帖最后由 phctgu 于 2011-5-30 17:54 编辑
最近再做一个案子,需要把STM8上的代码移植到STM32,但是发现STM32比较输出进不了中断,是哪里出错了呢?
APB1是8M CLK
------------------------
void sys_Occ3Init(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_Inactive; TIM_OCInitStructure.TIM_Pulse = 100; //翻转周期
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;//TIM输出比较极性低
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInit(TIM3, &TIM_OCInitStructure);
TIM_PrescalerConfig(TIM3,15,0x01);
TIM_Cmd(TIM3, ENABLE);
TIM_ITConfig(TIM3, TIM_IT_CC3 , ENABLE);
}
****中断函数****
void TIM3_IRQHandler(void)
{
if (TIM_GetITStatus(TIM3, TIM_IT_CC3) != RESET)
{
TIM_ClearITPendingBit(TIM3, TIM_IT_CC3 );
GPIO_Display( ); // 这里做一些IO口的处理
} |