zoukankan      html  css  js  c++  java
  • 测试中断程序理解

     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
  • 相关阅读:
    关于博客转移
    Leetcode 双周赛 42 题解
    Leetcode 220 周赛 题解
    Leetcode 双周赛 41 题解
    Leetcode 周赛 219 题解
    求解组成最大最小周长三角形
    友链
    维护日志
    投喂记录
    Scipy.optimization
  • 原文地址:https://www.cnblogs.com/wises/p/9539576.html
Copyright © 2011-2022 走看看