搞了2天了没搞出来,STC12C2052用PCA高速输出一个38KHZ的方波,咋整都不行,哪位有C源程序的发个过来学习哈?先谢谢了。
#include <REG2051.H>
sbit EPC0H=0XF3;
sbit EPC0L=0XF2;
sbit T0x12=0x95;
sbit T1x12=0x94;
sfr AUXR=0X8E;
sbit EPCA=IE^6;
sfr CL=0Xe9;
sfr CH=0xf9;
sfr CCON=0xd8;
sfr CCF0=0xd8;
sfr CCF1=0XD9;
sfr CF=0Xdf;
sfr CMOD=0xd9;
sfr CCAP0H=0xfa;
sfr CCAP1H=0xfb;
sfr CCAP0L=0xea;
sfr CCAP1L=0xeb;
sfr PCA_PWM0=0xf2;
sfr PCA_PWM1=0xf3;
sfr CCAPM0=0xda;
sfr CCAPM1=0xdb;
sfr IPH=0XB7;
sbit CR=0xde;
void PCA(void) interrupt 6
{
CCF1=0;
CCAP1H=0x00;
CCAP1L=0X4F;
CH=0X00;
CL=0X00;
}
//*******************************************************
main ()
{
SP=0x30;
CCAP1H=0x00;
CCAP1L=0X4F;
CMOD=0x02;
CCAPM1=0x4D;//01001101高速输出
CCON=0X00;//
IP|=0X40;
IPH|=0X40;//PCA中断最先
CH=0X00;
CL=0X00;
EPCA=1;
CR=1;
while (1);
} |