#include <reg52.H>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
unsigned char Pwm_Duty =0;
unsigned char Pwm_Duty1 =0;
unsigned char Pwm_Duty2 =0;
unsigned char Pwm_Duty3 =0;
unsigned char Pwm_Duty4 =0;
unsigned char Pwm_Duty5 =0;
unsigned char Pwm_Duty6 =0;
unsigned char Pwm_Duty7 =0;
unsigned char PWM_Cnt=0;
unsigned char p=0;
int i1=0;
int i2=0;
int i3=0;
int i4=0;
int i5=0;
int i6=0;
int i7=0;
int i8=0;
sbit rs = P2 ^ 6;
sbit rw = P2 ^ 5;
sbit en = P2 ^ 7;
sbit K1=P2^1;
sbit L1=P1^0;
sbit L2=P1^1;
sbit L3=P1^2;
sbit L4=P1^3;
sbit L5=P1^4;
sbit L6=P1^5;
sbit L7=P1^6;
sbit L8=P1^7;
void Delay(int i)
{ int j,k;
for(;i>0;i--)
for(j=15;j>0;j--)
for(k=11;k>0;k--);}
void Timer0Init(void)
//200微秒@12.000MHz
{
TMOD &= 0xF0; //设置定时器模式
TMOD |= 0x02; //设置定时器模式
TH0=240;//高八位
TL0=240; //设置定时初始值
TF0 = 0; //清除TF0标志
ET0 = 1;
EA = 1;
TR0 = 1; //定时器0开始计时
}
void timer0_Routine(void) interrupt 1 //T0中断程序
{
TH0=240;//高八位
TL0=240; //重装始值
//重装始值
PWM_Cnt++;
if(PWM_Cnt>=100)
{
PWM_Cnt=0;
}
|