Schematic diagram of clock circuit composed of AT89C2051

Publisher:浅唱梦幻Latest update time:2010-04-09 Source: 21icKeywords:AT89C2051 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

We use an actual clock circuit to illustrate the software programming method of the timer. The clock is our most common timing tool that displays hours, minutes, and seconds. It is a typical application representative.

The minimum unit of the clock is seconds, but if the microcontroller timer is used for timing, if a 6.0MHz crystal oscillator is used, even if it works in working mode 1, the maximum timing time can only reach 131ms, so we can take each timing time as 125ms, so that the timer overflows 8 times (125ms╳8=1000ms) to get the minimum unit of seconds. It is easy to achieve 8 counts using software methods.

We use timer 1, working in working mode 1, and the timer performs 125ms timing. The interrupt method is used to accumulate the number of overflow times. When the overflow times are reached 8 times, 1 second of timing is obtained.

The time accumulation of a clock requires multiple bases to realize the carry of minutes and hours. The carry of seconds, minutes and hours is in decimal, while the carry of seconds to minutes and minutes to hours is in sexagesimal. There is a twelve-hour system or a twenty-four-hour system every day, which are in duodecimal and twentieth-century respectively. From seconds to minutes and from minutes to hours can be realized through software accumulation and numerical comparison methods.

In the internal RAM of the single-chip microcomputer, it is necessary to set up a display buffer. The displayed hour, minute, and second values ​​are taken out from the display buffer. Four units are set up in the RAM as display buffers, namely 7AH, 7BH, and 7CH. In order to facilitate the description of the circuit and principle, we do not display the second value here. We realize the carry of the second by flashing the minute value. In this way, we have a total of four LEDs to display the hour and minute values ​​respectively. At the same time, the clock needs to be calibrated. In the program, it is also necessary to set up a display code table. The value to be displayed is sent to the LED through the table lookup instruction to send the real code value for display. We use the two I/O ports PP3.4 and P3.5 of the single-chip microcomputer AT89C2051 to connect micro switches to realize the correction of hours and minutes. Each time the hour or minute value is pressed, 1 is added. The value is accumulated by pressing continuously to realize the calibration of the clock.

We also set a buzzer in the circuit for simple time reporting. For example, we can set a wake-up time of 7:30 in the morning and another wake-up time of 1:30 in the afternoon. Each time it rings for 1 minute, 1 second, and stops for 2 seconds, instead of continuous ringing. We use the 12-hour system in this program. For this reason, we need to set the corresponding flags in the program to facilitate the recognition of the main program. There are also several related flags in the timing program, which are mainly used to control the direction of the program flow. We have made detailed comments in the program, so I will not repeat them here.

For the hardware circuit, we still use the low-cost AT89C2051 microcontroller as the microprocessor unit. This chip is compatible with the C51 instruction system. Programs written on C51 can be easily transplanted to this chip without any modification. We use P0 port as the field bit drive output of the LED. The "carry" of the second uses the fractional value flashing prompt, which is on for 0.5 seconds and off for 0.5 seconds. P3.1-P3.3 are used for bit drive, and the dynamic scanning method is used for display. The display time of each LED can be between 10-25ms. The scanning frequency cannot be too high, otherwise the display time of each LED is too short and the brightness is too low, which is not easy to watch. It is better to make the naked eye not feel the LED flickering. For the sake of intuitiveness, our drive output does not use integrated circuits, but uses discrete components-transistors, but the working principle is the same.

Schematic diagram of clock circuit composed of AT89C2051

This circuit structure determines that the LED uses a common anode digital tube, which can be LQ5101BS ordinary light-emitting diodes, and the driving transistors can use the easily available 2SA1015 and 2SC1815 models. Of course, low-power transistors such as S9012, S9013, S9014, 2N5401, 2N5555 can also be used. There are no special requirements for other devices. For the convenience of experiments, the single-chip microcomputer AT89C2051 can use a DIP20P socket. After the program is compiled and debugged without error, it can be burned into the AT89C2051. It is worth mentioning that AT89C2051 is a Flash program memory, and the program can be repeatedly erased and written, which is very convenient for experiments.

Keywords:AT89C2051 Reference address:Schematic diagram of clock circuit composed of AT89C2051

Previous article:Design of wireless transceiver system based on nRF905 module and C8051F microcontroller
Next article:Design of home appliance control system based on AT89S52 single chip microcomputer

Recommended ReadingLatest update time:2024-11-16 20:38

2440 bare board program clock initialization
The corresponding pins of LED are GPF4, GPF5, and GPF6.  The compiler used is arm-linux-gcc-4.5.1.  Includes four files head.S main.c main.lds Makefile. Experimental purpose: Increase the CPU main frequency to 400Mhz. (FCLK:400 HCLK:100 PCLK:50)     2440 uses MPLL and UPLL to multiply the crystal or external clo
[Microcontroller]
2440 bare board program clock initialization
Tangled STM32 RTC clock source LSE
At the beginning, all experiments were done on the Shenzhou board, and no RTC problems were found. It was not until we drew the board ourselves and debugged it that we found that there was a problem with the external clock source of the STM32 RTC. This is also a chicken rib of STM32. It is too demanding for the LSE ex
[Microcontroller]
Tangled STM32 RTC clock source LSE
Single chip electronic clock class design assembly language code and proteus simulation
  MCU assembly language source code: ORG 0000H AJMP MAIN ORG 000BH LJMP INTT0 ORG 0030H MAIN: MOV SP,#60H ; establish stack area MOV PSW,#00H MOV R0,#20H ; RAM area first address MOV R7,#5FH ; Number of RAM area units QL: MOV @R0,#00H ; RAM clear         INC R0 DJNZ R7,QL MOV IP,#02H ;IP initialization, priorit
[Microcontroller]
Single chip electronic clock class design assembly language code and proteus simulation
STM32 internal clock output PA.8 (MCO)
The PA.8 pin of STM32 has a multiplexing function - clock output (MCO), which can output the internal clock of STM32 through PA.8.  Operation process:     1) Set PA.8 to multiplexed Push-Pull mode.      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;      GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz;      GPIO_InitStr
[Microcontroller]
Clock, stopwatch, running lights MCU assembly program
 //HJSMSY-V1.0 MCU development board test program //--------------------------------------------- // Computer clock //---------------------------------------------     //=======Main function================================ ORG 0000H     LJMP MAIN     ORG 000BH     LJMP T00 // ORG 001BH // LJMP T11     ORG 0030H //
[Microcontroller]
DS1302 clock chip displays time C51 program
/* Program effect: Display time through DS1302 chip. This program mainly needs to understand the protocol of DS1302 chip, so as to facilitate programming. Of course, time display can also be controlled by the timer of the microcontroller, which is more accurate than the delay subfunction. */
[Microcontroller]
Increasing the number of outputs from a clock source using low-jitter LVPECL fanout buffers
Circuit Function and Advantages Many systems require multiple low jitter system clocks for mixed signal processing and timing. The circuit shown in Figure 1 interfaces the ADF4351 integrated phase-locked loop (PLL) and voltage controlled oscillator (VCO) to the ADCLK948, which provides up to eight differential, low vo
[Power Management]
Increasing the number of outputs from a clock source using low-jitter LVPECL fanout buffers
STM32 Series Chapter 16 - RTC Real-time Clock
RCT characteristics: Programmable pre-scaling factor, the maximum pre-scaling factor is 2 to the power of 20. 32-bit programmable count for measuring longer time periods. 2 separate clocks. Three RTC clock sources can be selected: HSE/128; LSE oscillator; LSI oscillator. 2 independent reset types: APB1 is reset b
[Microcontroller]
STM32 Series Chapter 16 - RTC Real-time Clock
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号