芯片是16F1936,晶振是8MHZ,目的是用CCP4输出一个1KHZ的方波,程序烧好后,通电工作,CCP4输出是4KHZ的方波,下面是源程序(省略了配置字),请问哪里出了问题?谢谢!
#include<xc.h>
void main(void) //output PWM by ccp4 together with timer2
{
TRISB0=0; //ccp4 selected
PR2=31; //1mS as cycle
T2CON=0x0f; //64 as prescaler
CCPTMRS0=0x00; //timer2 selected
CCP4CON=0x0f; //PWM selected
CCPR4L=0x10; //0.5 duty cycle
while(1) ;
} |