请问STM8S103中设置捕获PC6的信号,这样设置可以吗?高低电平时间都要捕获 请问这样设置捕获可以吗? TIM1_DeInit(); TIM1->SCRH=0X03; TIM1->SCRL=0X1F;//设置分频=800,计800/16=50us记数周期 TIM1->CCER1&=0XFE;//禁止输入捕获1 TIM1->CCMR1|=0X01;//PC6(CH1)到ti1fp1 TIM1->CCER1&=0XEC;//CH1 上升沿触发 TIM1->IER|=0X02;//势能中断CH1 TIM1->CCER1|=0X01;//使能输入捕获1 TIM1_Cmd(ENABLE);//使能计数 rim(); // 允许CPU全局中断 中断中的程序如下: if(TIM1_GetITStatus(TIM1_IT_CC1)) { TIM1_ClearITPendingBit(TIM1_IT_CC1); if(GPIOC->IDR&0x40) TIM1->CCER1|=0X02;//ch1 下降沿触发 else TIM1->CCER1&=0XEC;//ch1 上升沿触发 tmpcntr=TIM1_GetCapture1(); TIM1_Cmd(ENABLE);//使能计数 } |
RE:捕获中断设置
uint16_t Mt,St,tmpcntr;
INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
int d,l,j,e,f;
static int o=0,bs=0;
extern uchar Xsbuf[];
uchar h,i,b,Status[8],yxtrx[12],pluscode;
static uint16_t G32Tosc=0;
if(TIM1_GetITStatus(TIM1_IT_CC1))
{
TIM1_ClearITPendingBit(TIM1_IT_CC1);
if(GPIOC->IDR&0x40) TIM1->CCER1|=0X02;//ch1 下降沿触发
else TIM1->CCER1&=0XEC;//CH1 上升沿触发
tmpcntr=TIM1_GetCapture1();
TIM1_Cmd(ENABLE);//使能计数
}测试结果好象不能进入中断.请高手解答