首页 > 其他 > 详细

测试中断程序理解

时间:2018-08-27 00:04:58      阅读:253      评论:0      收藏:0      [点我收藏+]
技术分享图片
 1 #include <reg52.h>
 2 #define uchar unsigned char
 3 #define uint unsigned int
 4 sbit LA =P2^2;
 5 sbit LB =P2^3;
 6 sbit LC =P2^4;
 7 uchar t1,shu;
 8 uchar code table[]={
 9 0x3f,0x06,0x5b,0x4f,
10 0x66,0x6d,0x7d,0x07,
11 0x7f,0x6f,0x77,0x7c,
12 0x39,0x5e,0x79,0x71,
13 0x76,0x79,0x38,0x3f,0};
14 void main()
15 {
16     shu =8;
17     TMOD=0x01;
18     TH0=(65536-50000)/256;
19     TL0=(65536-50000)%256;
20     EA =1;
21     ET0 =1;
22     TR0 =1;
23     while(1);
24 
25 }
26 void timer0() interrupt 1
27 {
28     TH0=(65536-50000)/256;
29     TL0=(65536-50000)%256;
30     t1++;
31     if(t1==2)
32     {
33         t1 =0;       //如果t1 不清零的话,就会不停地加数,一直加到溢出后,从0开始重来这样时间就出现问题了
34         shu--;
35         LA =1;
36         LB =1;
37         LC =0;
38         P0 =table[shu];    
39         if(shu==2)
40         {
41             TR0 =0;
42         }
43     }
44 }        
View Code

 

测试中断程序理解

原文:https://www.cnblogs.com/wises/p/9539576.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!