加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

测试中断程序理解

发布时间:2020-12-14 03:48:09 所属栏目:大数据 来源:网络整理
导读: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 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,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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读