myproj.c

来自「暑假为学生培训写的51相关接口的所有源码及项目代码」· C语言 代码 · 共 30 行

C
30
字号
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
/*--------------------------parameter setting-----------------------*/
#define XtalFreq (11.059200)//Crystal Frequence

#define FALSE 0
#define TRUE 1
/*--------------------------sfr setting-----------------------*/
sfr CCAPM0=0xDA;//PCA module 0 mode
sfr PCACL=0xE9;//PCA timer Low BYTE

sfr CCAP0H=0xFA;//module 0 get High BYTE 
sfr CCAP0L=0xEA;//module 0 get Low BYTE 

sfr CMOD=0xD9;//PCA module timer mode
sfr CCON=0xD8;//PCA module timer control

sbit CR=0xDE;//The PCA Start Count
sbit CEX0=0x93;//PWM output CEX0 output P1.3
/*-------------------------------main-------------------------------*/
void main()
{
	//CCAP0L=0x4e;
	CCAP0H=0x01;//using for the control of the PWM pulse
	CMOD=0x80;//using the T0 overflow for the Count Pulse,none Interupt,none WDOG/remain count
    CCAPM0=0x42;//model 0 work state
	CR=1;//start the PCA Counter
	while(1);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?