STC89c52+DS1302 clock, digital tube displays time and date, adjustable

Publisher:upsilon30Latest update time:2020-09-18 Source: 51heiKeywords:STC89c52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I have been working on a digital electronic clock recently, and I have summarized some information to share with you. The DS1302 clock chip. The chips needed for computer simulation are AT89C52, 74HC138 resistor array (because the IO port of C52 microcontroller P0 does not have a pull-up resistor), 74HC245. If you need to make a real thing, you have to choose the appropriate resistor according to the model of the digital tube, DS1302 chip, button


1. Working principle
Let's first understand what we are using. STC89C52 is an 8051 microcontroller, which will not be introduced here. Then there is the DS1302 clock chip.

This is the DS1302 clock chip.
top.png
This is the working principle. We often use the connection between the DS1302 and the microcontroller.
Working principle.png
2. Experimental ideas
Understand the data transmission between the DS1302 clock chip and the microcontroller. The single bus method is used, so there will be a timing diagram and a read-write
Write data transmission.png
clock.png
diagram third is the address. If we read a minute or hour, the data we read is 0x82, and if it is to write minutes, it is 0x83, but it is not that simple. We have to turn off the read-write protection before performing the operation, so that we can read and write.


3. Experimental simulation diagram
time.png
Date.png
We first need to know how to use 74HC138 and 74HC245 chips. The data sheets of these two chips are attached in the compressed package. You can refer to the manual. In actual production, the IO of the microcontroller cannot directly drive the digital tube, because the current of the digital tube is relatively large, and the IO port of the microcontroller does not have such a large driving current, so it can be determined by triodes or driver chips and resistors. The resistance value of the resistor depends on the rated current and resistance of the digital tube. Because there is no such in proteus, I did not do it so carefully here. The use of the button is K3 to pause the time, K1 is to select the time to be adjusted, and K2 is to add one. Press K3 again to restore the time and make it move. The only disadvantage is that you cannot see it when adjusting the time.


4. Experimental source code
There is a lot of experimental source code. I put the source code, the data manual, and the simulation diagram in a compressed package. You can download them if you need them. The software used is KELI4 Proteus8.7. There are many of these two software on the Internet. Please download them by yourself. I will not go into details here.


5. Experimental extension
Because our digital tube display is displayed one by one, because the time is extremely short, the effect comes out together. We use timer 1 to switch time and date, but we have been consuming a lot of power for a long time, so we can set the sleep mode, that is, use PCON=0x02; enter sleep, and then the external interrupt can be used. STC89C52 has four interrupt wake-up. We can use these four external interrupts to achieve the effect of power saving, PCON=0x00; wake up the microcontroller. This is just a personal idea, and this idea has not been integrated. If you have ideas, you can also make improvements. I hope you like it. .

Keywords:STC89c52 Reference address:STC89c52+DS1302 clock, digital tube displays time and date, adjustable

Previous article:STC15 MCU uses ESP8266 to control LED source code
Next article:Programming of Single Chip Microcomputer Intelligent Temperature Detection and Control System

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号