单片机数字时钟课程设计

loading 分享 2026-8-13 下载文档

[4]许熙文.电路基础[M].北京:高等教育出版社,1999:91-95.

[5]李军.51系列单片机高级实例开发指南[M].北京:北京航空航天出版社,2008:20-70.

#include #define uchar unsigned char #define FLASH_FREQ 100 sbit KEY1 = P1^4; sbit KEY2 = P1^5;

#define COM1_ON (P2=0xf7) //1111 1110

#define COM2_ON (P2=0xfb) //1111 1101

#define COM3_ON (P2=0xfd) //1111 1011

#define COM4_ON (P2=0xfe) //1111 0111

#define COMS_OFF (P2=0xff) #define SEG_PORT (P0) uchar

code

LED_Tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};

#define DISPLAY_BIT 4

uchar DisBuff[DISPLAY_BIT];

bit DisDecemal=0;

uchar shi=11,fen=59,miao=49;

void delay(uchar ms) { }

void LED_DisplayTimer(uchar LED1,uchar LED2,uchar LED3,uchar LED4)

uchar i,j;

for(i=ms;i>0;i--)

for(j=122;j>0;j--);

{ }

void Timer0_Init(void) {

DisBuff[0]=LED_Tab[LED1];

DisBuff[1]=LED_Tab[LED2];

DisBuff[2]=LED_Tab[LED3];

DisBuff[3]=LED_Tab[LED4];

if(DisDecemal==1)

DisBuff[1]&=0x7f;

TMOD=0x01;

}

TH0=(65536-5000)>>8; TL0=(65536-5000); IE=0x82; TR0=1;

void Display_Scan(void) {

static uchar COM; COM++;

if(COM>=DISPLAY_BIT) COM=0;

COMS_OFF;

switch(COM)


单片机数字时钟课程设计.doc 将本文的Word文档下载到电脑
搜索更多关于: 单片机数字时钟课程设计 的文档
相关推荐
相关阅读