我用的是picc9.70 ,
程序如下,但是没有pwm信号输出,不知道原因在哪里?
理论上,程序是没有问题的,真奇怪啊
#include <pic.h> //the source definition of the MCU
__CONFIG(INTCLKO & WDTDIS & PWRTDIS & MCLREN & UNPROTECT & BORDIS & BORV25 & PLLEN & DEBUGEN ); //INTOSC
__CONFIG(VCAPDIS);
void main()
{
//initialize();
pwm_initialize();
pwm_enable();
for(;;)
{
}
}
void pwm_initialize()
{
//condition ,8Mhz ,4.9khz pwm ,timer_prescaler 4,max resolution 8bits
RC2 = 1;
PR2 = 0X65;
CCP1CON = 0B00001100;
//pwm duty cycle value
CCPR1L = 0X20;
//
TMR2IF = 0;
//T2CON &= 0X01;
T2CKPS0 = 1;
T2CKPS1 = 0;
TMR2ON = 1;
}
void pwm_enable()
{
RC2 = 0;
}
void pwm_disable(void)
{
RC2 = 1;
} |