Timer interrupt 0~100 seconds

Publisher:wmghyuLatest update time:2015-07-24 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The circuit is very simple, I won't draw a picture, the four-digit digital tube is connected through two 74hc595, one 595 is responsible for segment selection, and the other 595 is responsible for bit selection. The timer interrupt of the microcontroller is used to realize the 0-100 digital cycle display. The program has passed my test.
#include
#define uint unsigned int
#define uchar unsigned char
sbit rck=P0^0;
sbit sck=P0^1;
sbit si=P0^2;
uchar num[]={0x80,0xed,0x42,0x48,0x2c,0x18,0x10,0xcc,0x00,0x08};
uint b=0,i=0,j=0,k;
void write_595(uchar x) // Initialize the 595 chip
 {
  for(k=0;k<8;k++) //shift register
   {
    x>>=1;
 sck=0;
 si=CY;
 sck=1;
   }
 }
void date_danpianji()//Initialize the MCU timer

 {
  EA=1; //General interrupt enabled
  ET1=1; //Timer on
  TMOD=0X10; //Select timer working mode
  TH1=(65536-33333)/256; //Division is assigned to the upper eight bits
  TL1=(65536-33333)%256; //The remainder is assigned to the eighth bit
  TR1=1; //Start the timer
 }
void main()//main function
 {
  date_danpianji(); //Call timer interrupt
  while(1) // loop
   {   
    if(b==20) //Check if the interrupt function satisfies b==20, if so, execute
     {
   b=0;
   i++;
   if(i==10)
    {
     i=0;
     j++;
     if(j==10)j=0;
    }
  }
    write_595(num[j]);
    write_595(num[i]);
    rck = 0 ;
    rck = 1 ;
   }
 } 
void ext() interrupt 3 using 1 //timer interrupt
{
  TH1=(65536-33333)/256;
  TL1=(65536-33333)%256;
  b++;
}
 
Reference address:Timer interrupt 0~100 seconds

Previous article:1602 LCD 8-bit data port dynamic display
Next article:Wireless identification device debugging experience

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号