Digital clock production of 89C52 single chip microcomputer

Publisher:温柔心绪Latest update time:2016-01-08 Source: eefocusKeywords:89C52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
This is similar to the digital stopwatch in the previous article, except that it has four seven-segment displays, and the entire display is divided into three parts: hours, minutes, and seconds. When the hour is 24, it is set to 0, when the minutes are 60, it is set to 0 and incremented by 1, and when the seconds are 60, it is set to 0 and incremented by 1.
  program:
#include
#include
 
 
void delay(unsigned char dly)
{
  unsigned char i,j;
 
  for(i=100;i>0;i--)
    for(j=dly;j>0;j--)
;
}
unsigned char num,time1,time2,time3;
void   timer0()interrupt 1
{
  TH0=(65535-46080)/256;
 
  TL0=(65535-46080)% 256;
  num++;
  if(num==20)
    {
 num=0;
 time1++;
}
}
void intial()
{
  TMOD=0x01;
  ET0=1;
  EA=1;
  TR0=1;
  num=0;
  time1=0;
  time2=0;
  time3=0;
}
void main()
{
  unsigned char table[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
  unsigned char shi,fen;
  intial();
  while(1)
    {
if(time1==60)
 {
   time1=0;
time2++;
 }
if(time2==60)
 {
     time2=0;
   time3++;
 }
 if(time3==24)
   time3=0;
shi=time1/10;
fen=time1% 10;
P2=0xf7;
P0=table[shi];
delay(2);
P2=0xfb;
P0=table[fen];
delay(2);
shi=time2/10;
fen=time2% 10;
P2=0xdf;
P0=table[shi];
delay(2);
P2=0xef;
P0=table[fen];
delay(2);
shi=time3/10;
fen=time3% 10;
P2=0x7f;
P0=table[shi];
delay(2);
P2=0xbf;
P0=table[fen];
delay(2);
}
}

Keywords:89C52 Reference address:Digital clock production of 89C52 single chip microcomputer

Previous article:89C52 single chip microcomputer key control
Next article:Implementing a digital clock on LCD

Recommended ReadingLatest update time:2024-11-16 13:39

Clock Design Based on 89C52 Single Chip Microcomputer
This is my first time posting on the forum. I won't say much, just go straight to the point. I have always liked microcontrollers. Recently, I have some time to make a board with a 51 microcontroller. From circuit board production to final debugging, I did it all by myself. The schematic diagram is very simple, the
[Microcontroller]
Clock Design Based on 89C52 Single Chip Microcomputer
Digital clock production of 89C52 single chip microcomputer
This is similar to the digital stopwatch in the previous article, except that it has four seven-segment displays, and the entire display is divided into three parts: hours, minutes, and seconds. When the hour is 24, it is set to 0, when the minutes are 60, it is set to 0 and incremented by 1, and when the seconds are 6
[Microcontroller]
Practical eight-channel level measuring instrument based on 89C52 single chip microcomputer
1. Overall composition The signal sampling of this measuring instrument can accept eight standard TTL levels after shaping through the eight input lines of the P0 port, so it can measure the pulse type level sampling signals from different sensors, as long as the original signal is shaped, each pulse is cap
[Microcontroller]
Practical eight-channel level measuring instrument based on 89C52 single chip microcomputer
MCU music program
Using a single-chip microcomputer (or single-board computer) to play music is probably one of the issues that radio enthusiasts are interested in. This article starts with the basic experiment of single-chip microcomputers, discusses the design principles of music programs, and gives specific examples for reference. T
[Microcontroller]
MCU music program
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号