includeincludedefineFOSC110592000L这个是long型数据,110595mhztypedefunsignedcharBYTE;typedefunsignedintWORD
#include
#include
#define FOSC 110592000L//这个是long型数据,11.0595mhz
typedef unsigned char BYTE;
typedef unsigned int WORD;
sfr CCON = 0xD8;
sfr CMOD = 0xD9;
sfr CCAP0L = 0xEA; //PCA 模块 0 的捕捉/比较寄存器低 8 位。 0000,0000
sfr CCAP0H = 0xFA;
sfr CL = 0xE9; //PCA 计数器低位 0000,0000
sfr CH = 0xF9; //PCA 计数器高位
sfr AUXR = 0x8E;
sbit CR = CCON^6;
sfr CCAPM0 = 0xDA;
sfr PCAPWM1=0xf3;
sfr CCAP1H=0xfb;
sfr CCAP1L=0xeb;
void main()
{
CCON=0;//操控寄存器
CL=0;
CMOD=0x02;//操控频率的,f=fosc/2
CCAP0H=CCAP0L=0x80;//占空比为50%
CCAPM0=0x42;//八位pwm
CCAP1H=CCAP1L=0xff;//占空比0%
PCAPWM1=0x03;//占空比0%
CCAPM0=0x42;
CR=1;//PCA timer startrun
while(1);
}
两路pwm输出,设置频率和占空比
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/yingyong/chuanganqi/256581.html