void TIM2_Excnt_Init(u16 arr,u16 psc)
{
RCC->APB1ENR |=1<< 0;//ê1Äü¶¨ê±Æ÷2£¬TIM2
RCC->APB2ENR|=1<<2; //ê1ÄüPORTAê±Öó
GPIOA->CRL &= 0XFFFFFF0F;//PA1Çåáã
GPIOA->CRL |= 0X00000080;//êäèë
GPIOA->ODR|=0<<1; //PA1 ÏÂà-
TIM2->ARR=arr; //??????????
TIM2->PSC=psc; //????
TIM2->CCMR1|=1<<8; //CC2S=10 Ñ¡Ôñêäèë¶Ë IC2ó3éäμ½TI2éÏ
TIM2->CCMR1|=0<<12; //IC2F=0001 ÅäÖÃêäèëÂË2¨Æ÷ 2»ÂË2¨
TIM2->CCER|=0<<5; //CC2P=0 éÏéyÑØ2¶»ñ
TIM2->SMCR|=5<<4; //????:?????????1(TI1FP1)
TIM2->SMCR|=7<<0; //??????1
TIM2->CR1|=1<<0; //?????,CEN=1
}
TIM2_Excnt_Init(0XFFFF,0);
while(1)
{
if(oldcnt!=TIM2->CNT)
{
oldcnt=TIM2->CNT;
usRegHoldingBuf[0]=oldcnt;
}
}
}
为什么用TIMer2的CH2,也就是PA1,不能做外部计数啊。各位大神能指导下吗
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>