#include "REG51.h"
#include "h/Port.h"
#include "h/key.h"
#include "h/led.h"
void tim(void) interrupt 1 using 1 //定时器
{
TH0=0xe5;
TL0=0xe0;
KeyLedDisplay(); //这个子程序放在主程序中能正常显示
TestLED = !TestLED; //定时器已工作频率1K Hz
}
void writeByte595(unsigned char num)
{
unsigned char c;
for(c=0;c<8;c++)
{
CLK=0;
DAT=num&0x80;
num=num<<1;
CLK=1;
}
}
void WriteWord595(unsigned char Addr,unsigned char Dat)
{
char i=0;
writeByte595(Addr);
writeByte595(Dat);
RCLK=0;
i=0;
i=1;
// nop();
RCLK=1;
}
void KeyLedDisplay()
{
static unsigned char i=0;
i+=1;
if(i>1) i=0;
ReadSign_LED();
switch(i)
{
case 0: WriteWord595(0xfe,DISPLED.SByte.SByteH);break;
case 1: WriteWord595(0xfd,DISPLED.SByte.SByteM);break;
}
} |