#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define FOSC 11059200
sbit EPCAI=IE^6;
sfr CCON=0xD8;
sbit CCF0=CCON^0;
sbit CCF1=CCON^1;
sbit CR=CCON^6;
sbit CF=CCON^7;
sfr CMOD=0xD9;
sfr CL=0xE9;
sfr CH=0xF9;
sfr CCAPM0=0xDA;
sfr CCAP0L=0xEA;
sfr CCAP0H=0xFA;
sbit ENA=P1^7;
sbit clk=P3^5;
unsigned long num,num1;
bit flag;
void main()
{
ENA=1;
CCON=0;
CL=0;
CH=0;
CMOD=0x02;
num=200;
CCAP0L=0-num;
CCAP0H=0-num;
// num+=T100Hz;
CCAPM0=0x49;
CR=1;
EPCAI=1;
EA=1;
num1=0;
while(1);
}
void PCA_isr() interrupt 7
{
static int aa=1;
CCF0=0;
CL=0;
CH=0;
aa++;
if((aa>=500)&&(num<=254))
{
aa=0;
num++;
if(num<=254)
{
CCAP0L=0-num;
CCAP0H=0-num;
}
else
{
num=255;
}
}
clk=~clk;
}
我想实现脉冲逐渐加大,但是为什么到了5000就上不去了呢??? |