基于51单片机的8位数码管显示的可调时电子时钟
本人大二本科生,第一次发东西,功能比较简单,代码有点复杂,希望能有大神指正。
- 基于51单片机的不可调时间的时钟显示,晶振为11.0592MHZ,60HZ左右刷新一次,用了两个定时器,定时器0负责LED循环显示,定时器1负责定时,大概200秒左右落后1秒。
#include <REGX51.H>
#include <intrins.h>
void begin();
void ledshow();
unsigned char number[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x40};
unsigned char wei[]={0xe3,0xe7,0xeb,0xef,0xf3,0xf7,0xfb,0xff};
unsigned char num[8];
unsigned char hour,min,sec;
int main(){
begin();
hour=8;
min=56;
sec=00;
while(1){
ledshow();
}
}
void begin(){
TMOD &= 0xF0; //???????
TL0 = 0x18; //??????
TH0 = 0xC4; //??????
TF0 = 0; //??TF0??
TR0 = 1; //???0????
TMOD &= 0x0F; //???????
TMOD |= 0x10; //???????
TL1 = 0x00; //??????
TH1 = 0xF7; //??????
TF1 = 0; //??TF1??
TR1 = 1; //???1?