Detailed description of the usage skills of AT89S51 microcontroller timing counter

Publisher:NatureLoverLatest update time:2023-10-04 Source: elecfansKeywords:AT89S51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Experimental tasks

Use the AT89S51 timer/counter T0 to generate a 2-second timing. Whenever the 2-second timing arrives, the replacement indicator light flashes. The frequency of each indicator flash is 0.2 seconds. That is to say, the L1 indicator light starts at a rate of 0.2 seconds. Flashing, when the 2-second timer arrives, L2 starts flashing at a rate of 0.2 seconds, and the cycle continues. The flashing rate of 0.2 seconds is also completed by the timer/counter T0, which is a flashing light.

2. Circuit schematic

Figure 4.16.1


3. System board hardware wiring

(1. Connect P1.0-P1.3 in the "MCU System" area to L1-L4 in the "Eight-way LED Indicator Module" area with wires


4. Programming content

(1. Since it is done in the interrupt mode, the interrupt source must have its interrupt entry address. For the timer/counter T0, the interrupt entry address is 000BH, so a long jump instruction is added to the interrupt entry to perform the interrupt service. Program. The format of writing assembly source program is as follows:

ORG00H

LJMPSTART

ORG0BH ;Timer/counter T0 interrupt entry address

LJMP INT_T0

START: NOP; main program starts

.

.

INT_T0: PUSH ACC; timer/counter T0 interrupt service routine

PUSH PSW

.

.

POP PSW

POP ACC

RETI; Interrupt service routine returns

END

(2. Timing 2 seconds, using 16-bit timing 50ms, a total of 40 times to reach 2 seconds. An interrupt is generated every 50ms. The 40 times of timing are completed in the interrupt service program. The same timing of 0.2 seconds requires 4 times. It can reach 0.2 seconds. For the interrupt program, the interrupt must be disconnected in the main program.

(3. Since each time the 2-second timer expires, L1-L4 will flash alternately. ID numbers are used to identify them. When ID = 0, L1 is flashing, when ID = 1, L2 is flashing; when ID = 2 When, L3 is flashing; when ID=3, L4 is flashing


5. Block diagram

T0 interrupt service program block diagram


Keywords:AT89S51 Reference address:Detailed description of the usage skills of AT89S51 microcontroller timing counter

Previous article:How to use AT89S51 microcontroller to realize the design of home voice alarm system
Next article:Design of AT89C52 microcontroller to light up the digital tube

Recommended posts

EEWORLD University Hall----Live Replay: Anlu's new FPSoC product SF1 series FPGA+MCU, Demo board introduction and case analysis
Livereplay:Anlu'snewFPSoCproductSF1seriesFPGA+MCU,demoboardintroductionandcaseanalysis:https://training.eeworld.com.cn/course/67940
hi5 Integrated technical exchanges
【Qinheng Trial】7. TouchKey
ThisexperimentusesthetouchbuttonfunctionoftheADCmoduleonCH549,andusesthefourtouchbuttonsK1,K2,K3,andK4connectedtoP00,P01,P02,andP03ontheCH549EVTlearningdevelopmentboardtocontrolthefourLEDsconnectedtoP22,
lising Domestic Chip Exchange
【Ateli AT-START-F435】GPIO Interpretation (ODR, SCR, HDRV maximum current driving/sinking capability)
AT32F435supportsupto116bidirectionalI/Opins,whicharedividedinto8groups,namelyPA0-PA15,PB0-PB15,PC0-PC15,PD0-PD15,PE0-PE15,PF0-PF15,PG0-PG15,PH0-PH3.Eachpincanrealizethefunctionsofexternalcommunication,controland
zhangbaoyin Domestic Chip Exchange
【Anxinke BW16-Kit】Unboxing and First Experience
TheBW16-KitdevelopmentboardconsistsoftheASINCOBW16moduleandthebaseboard.TheBW16moduleusestheREALTEKRTL8720DNdual-bandWi-Fi+BluetoothSoCsolution,integratingARMV8(compatiblewithCortex-M4F)high-performanceMCU,ARMV8
dirty RF/Wirelessly
Peripheral circuit design issues of synchronous buck chip
Asshowninthefigure,therearetworecommendedapplicationdiagramsintheusermanualofthesynchronousbuckchipMPQ4323.ItalsoclearlyexplainstheperipheraldesignofPIN4,thefrequencysettingpin,andusesanexternalresistortogroun
shaorc Power technology
[Digi-Key Follow me Issue 2] Custom Task: ESP32 Controlled Amplifier
Inthesecondphaseoftheevent,IboughtXIAOESP32C3tocompletetheorder.ItsupportsArduinodevelopment,isveryconvenient,andhasaveryminisize.Theboardcomeswithalithiumbatterychargingchip,andisveryplayable. TheAD52
dql2016 DigiKey Technology Zone
Latest Microcontroller Articles
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号