Use T1 timing to output square waves with periods of 2ms and 500 microseconds at the P1.0 and P1.1 pins respectively.

Publisher:Qinghua2022Latest update time:2018-05-11 Source: eefocusKeywords:Timing Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Design a program for the 51 single-chip microcomputer. It is known that the crystal oscillator frequency of the 89C51 single-chip microcomputer is 12MHz, and
it is required to use T1 timing to output square waves with periods of 2ms and 500 microseconds at the P1.0 and P1.1 pins respectively.

Best answer:
;===================================================
The assembly program is as follows:

    ORG 0000H
    SJMP START
    ORG 000BH
    SJMP T0_INT
;------------------------------------
START:     
    MOV TMOD, #2 ;T0 timing mode 2
    MOV TH0, #6 ;Can automatically load the initial value.
    MOV TL0, #6 ;Timing
    SETB TR0 ;Start T0
    MOV IE, #82H ;Enable T0 interrupt.
    SJMP $ ;Wait for interrupt.
;------------------------------------
T0_INT: ;Execute once every 250us.
    CPL P1.1 ;Output square wave with a period of 500us.
    INC B
    MOV C, B.2
    MOV P1.0, C ;Output square wave with a period of 2000us.
    RETI
;------------------------------------
END

The above procedure has been verified by PROTEUS. 


Keywords:Timing Reference address:Use T1 timing to output square waves with periods of 2ms and 500 microseconds at the P1.0 and P1.1 pins respectively.

Previous article:Simple digital frequency meter based on 51 single chip microcomputer
Next article:Design of Second and Minute Pulse Generator of Single Chip Microcomputer by Interrupt Method

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号