用stc15f2k60s2的pca产生pwm控制呼吸灯,但没有呼吸灯效果,请大神指导
[复制链接]
#include
#define uint unsigned int
#define uchar unsigned char
unsigned char code bijiaozhi[40]={
1,1,2,2,3,4,6,8,10,14,19,25,33,44,59,80,107,143,191,255,
255,191,143,107,80,59,44,33,25,19,14,10,8,6,4,3,2,2,1,1};
void pcaInit();
void main()
{
void pcaInit();
while(1);
}
void PCA_ISR() interrupt 7
{
uchar cnt=0;
CCF0=0;
cnt++;
if(cnt>=39)cnt=0;
TL0=0;
TH0=0;
CCAP0H=bijiaozhi[cnt];
}
void pcaInit()
{
CCON=0X41;
CMOD = 0x04;
CL = 0x00;
CH = 0x00;
CCAP0L = 0x80;
CCAP0H = 0x80;
CCAPM0 = 0x4F;
EA=1;//打开总中断
CR=1;//开始计数
}
|