各位求助:
我用stm8的time1,其中CC3配置为俘获输入(遥控码接受),CC4配置为PWM输出,结果只要写入ARRH,ARRL时,就只能输出PWM,遥控码不能接收, 好像时基改变了,俘获值不对,无法识别遥控码:
程序如下:
//TIM1_CC1用做REMOTE input capture
TIM1_CCER2&=0xfe; //捕获关
TIM1_CCMR3=0x01; //输入捕获
TIM1_PSCRH=0x00; //分频,决定计数单位 fCK_PSC/( PSCR[15:0]+1)=8M/16=2us
TIM1_PSCRL=0x0f;
//TIM1_CNTRH = 0;
// TIM1_CNTRL = 0;
TIM1_CCER2|=0x02; ///下降沿
TIM1_CCER2|=0x01; ///使能捕获
TIM1_IER|=0x08; //允许中断
//TIM1_CR1_CEN=1; //使能time1
TIM1_CCMR4=0x60; //PWM MODE1 输出
TIM1_ARRH=0x00;
TIM1_ARRL=0x28; //12.5k=80us=2usx40
TIM1_CCR4H=0x00;
TIM1_CCR4L=0x14; //duty cycle=CCR/ARRx100
TIM1_CCER2|=0x10; //输出使能
TIM1_BKR|=0x80;
TIM1_CR1_CEN=1;
请帮忙 |