標(biāo)題: 請(qǐng)問(wèn)這個(gè)case 3為什么不能執(zhí)行? [打印本頁(yè)]

作者: 戴默遠(yuǎn)    時(shí)間: 2017-11-10 11:01
標(biāo)題: 請(qǐng)問(wèn)這個(gè)case 3為什么不能執(zhí)行?
#include <reg51.h>
#define LED P0
sbit P17=P1^7;
sbit LSA=P2^0;
sbit LSB=P2^1;
sbit LSC=P2^2;
unsigned char code discode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char disp[]={0x3f,0x3f};
unsigned int n=0,second=0,i=0;
void delay(unsigned int i)  //Ñóê±oˉêy
{
unsigned int j;
for(i;i>0;i--)
  for(j=110;j>0;j--);
}
void display()  //ÏÔê¾oˉêy
{
  LED=0;
        switch(i)  //λѡ
        {
                case(0):
                {
                        LSA=0;LSB=0;LSC=0;break;
    }
                case(1):
                {
                        LSA=1;LSB=0;LSC=0;break;
    }
        }
        LED=disp[i];  //¶ÎÑ¡
  i++;
  if(i>1)
        {
                i=0;
  }               
                       
}
void main()
{
        TMOD=0x61;  //3õê¼»ˉ
        IE=0x8B;
  IT0=1;
        TH1=0xE7;
        TL1=0xE7;
        TR1=1;
        while(1)
  display();  //ÎTÏTÑ-»·ÏÔê¾oˉêy
}
void int0() interrupt 0  //ía2¿ÖD¶Ï0
{
        n++;

        switch (n)
         {
                case 1:   //n=1,¿aÆô¶¨ê±Æ÷0£¬¼Æê±20ms
                {
                  TH0=0xB1;
                        TL0=0xE0;
                        TR0=1;
                        break;
    }
                case 2:  //n=2,1رն¨ê±Æ÷0
                {
                        TR0=0;
                        break;
    }
                case 3:  //n=3,Çåáã
                {
                        n=0;
      LED=0x3f;
                        break;
    }
        }
}
void intt0()  interrupt 1 //¶¨ê±Æ÷0ÖD¶Ï
{
        if(P17==1)  //2úéúÖüÆúÎa40msμÄÂö3å
        {
                P17=0;
  }
        else
        {
                P17=1;
        }
        TH0=0xB1;
        TL0=0xE0;
        TR0=1;
}
void intt1()  interrupt 3 //¶¨ê±Æ÷1ÖD¶Ï
{  second++;
         if(second==11)
         {
                 second=0;
   }
        disp[0]=discode[second%10]; //½«ÏÔê¾′úÂëËíèëÏÔê¾êy×é
        disp[1]=discode[second/10];
        TH1=0xE7;
        TL1=0xE7;
        TR1=1;
}
這個(gè)是按一次開(kāi)始計(jì)時(shí),再按一次停止,再按一次清零的。但是第三次按并不能清零,顯示的數(shù)字不變。

捕獲.JPG (222.56 KB, 下載次數(shù): 37)

捕獲.JPG





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1