T0 as timer assembly program (interrupt method)

Publisher:骄阳少年Latest update time:2015-04-30 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Assembly program for using MCU T0 as timer to realize digital tube display (interrupt method) 

The circuit is: P0 port is connected to the font code pen segment of the digital tube, and P2 port is connected to the digital selection end of the digital tube. 

下面是汇编语言源程序: 
  SECOND EQU 30H
   TCOUNT EQU 31H
    ORG 00H
    LJMP START
    ORG 0BH
    LJMP INT0X
START: MOV SECOND ,#00H
    MOV A,SECOND
    MOV B,#10
    DIV   AB
    MOV DPTR,#TABLE
    MOVC A,@A+DPTR
    MOV P0,A
    MOV A,B
    MOVC A,@A+DPTR
    MOV P2,A
    MOV TCOUNT,#00H
    MOV TMOD,#01H
    MOV TH0,#(65536-50000)/256
    MOV TL0,#(65536-50000) MOD 256
    SETB TR0
    SETB ET0
    SETB EA
    SJMP $
INT0X: MOV TH0,#(65536-5000)/256
           MOV TL0,#(65536-5000) MOD 256
     INC TCOUNT
     MOV A,TCOUNT
     CJNE A,#20,NEXT
     MOV TCOUNT,#00H
     INC SECOND
     MOV A,SECOND
     CJNE A,#60,NEX
     MOV SECOND,#00H
NEX: MOV A,SECOND
      MOV B,#10
      DIV AB
      MOV DPTR,#TABLE
      MOVC A,@A+DPTR
      MOV P0,A
      MOV A,B
      MOVC A,@A+DPTR
      MOV P2,A
NEXT:  RETI
TABLE: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
       END

T0 works in mode 1, timing 50ms, a total of 20 cycles, totaling 1 second.

P0 port displays low, P2 port displays high, and resets to zero when 60 is reached

Reference address:T0 as timer assembly program (interrupt method)

Previous article:Compile HEX microcontroller files using c51 command line
Next article:Single chip advertising light program (lookup table method)

Recommended ReadingLatest update time:2024-11-16 15:46

CC2530 bare metal programming series notes 3--Timer Timer1 free mode program
Timer 1 is a 16-bit timer with timer/counter/pulse width modulation functions. It has 3 individually programmable input capture/output comparison channels, each of which can be used as a PWM output or to capture the edge time of the input signal (for more information on what input capture/output comparison is and how
[Microcontroller]
TIMER0 controls a single LED to flash
The program C language source code is as follows: /* INT1 interrupt 5-bit count */ #include reg51.h typedef unsigned char uint8; typedef unsigned int uint16; sbit LED = P0^0; uint16 T_Count = 0; void main() { TMOD = 0x01; TH0 = 0xFC; TL0 = 0x67; IE = 0x82; TR0 = 1; while(1); } void LED_Flash() interrupt 1
[Microcontroller]
TIMER0 controls a single LED to flash
AVR microcontroller T0 use
This article introduces the use of T0 of ATmega 16 microcontroller T0 in M16 is an 8-bit timer/counter The following content is extracted from ATmega 16 Datasheet Note that OC0 must be set to output before use, and the pull-up resistor Use CTC method to generate 38K square wave. void timer0_init(void) //CTC
[Microcontroller]
AVR microcontroller T0 use
【stm32f103】Use of TIMER basic timing function (register version)
1. TIMER STM32 Block Diagram As shown in the figure: 1 is the clock source ● Internal clock (CK_INT) ● External clock mode 1: external input pin (TIx) ● External clock mode 2: External trigger input (ETR) ● Internal trigger input (ITRx): Use one timer as the prescaler of another timer. For example, you can
[Microcontroller]
【stm32f103】Use of TIMER basic timing function (register version)
STC15 series MCU timer components
/**  * File name: timer.h  */   #ifndef _TIMER_H #define _TIMER_H   #define SYS_MCLK 11059200 //System main clock #define FOSC 11059200 //Crystal oscillator frequency       #define USING_T0 #define USING_STC15_T2       #ifdef USING_T0 extern uint8_t tmr0LowByte, tmr0HighByte; void tmr0_init(uint8_t ms); #endif      
[Microcontroller]
MPLAB X IDE V4.2-2: How to use PIC10F200's TIMER0 timing
Since I have just come into contact with PIC microcontrollers, I need to study carefully. The delay method I use: The work requires PIC10F200 for timing: 1 Initially I used a simple delay() to implement However, this delay is not accurate, and because the crystal oscillator accuracy of each PIC10F200 chip is d
[Microcontroller]
MPLAB X IDE V4.2-2: How to use PIC10F200's TIMER0 timing
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号