Using timers to achieve long delays

Publisher:科技奇才Latest update time:2011-02-25 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

;Key points: Application of counters

; Set the timer to 50ms, and set two software counters to 20 and 60 for the total time

; 50ms*20*60=60000ms=1 minute

; t1 is mode 1, then m1m0=01h, use timer c/t=0 gate=0 TMOD=10H

; Mode 1 is a 16-bit counter, a total of 65535, minus 50000 equals 15536, so the initial value of the counter is 3cb0h

ORG 0000H; program starts

LJMP MAIN

ORG 030H

MAIN: MOV 30H, #20; 30h, 31h set constants 20, 60 respectively

MOV 31H,#60;

MOV TMOD,#10H;Timer mode 1

MOV TH1,#03CH; Set the timer initial value

MOV TL1,#0B0H

MOV IE,#00H; Disable interrupts

SETB TR1; Start timer

LOOP: JBC TF1, LOOP1; query timer time is up and switch to loop1

AJMP LOOP

LOOP1: MOV TH1,#03CH; reset timer

MOV TL1,#0B0H

DJNZ 30H,LOOP; Is the timing reached 20 times?

MOV 30H,#20

DJNZ 31H, LOOP; Is the timing up to 60 times?

MOV 31H,#60

CPL P1.0; invert p1.0

AJMP LOOP

END

The status of the program running in the Yitian version: the program is completely destroyed after running

The program is running in the Yitian version: p10 lights up after 1 minute, achieving a long delay

Reference address:Using timers to achieve long delays

Previous article:Control lights with buttons
Next article:Nesting of subroutines

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号