Home > other >  Novice (single-chip microcomputer) interrupt and timer T1
Novice (single-chip microcomputer) interrupt and timer T1

Time:09-27

Help everybody look at the following code where is wrong, if use a timer T1 development board has no response, no error message, thank you,


#include

Sbit ADDR0 P1=^ 0;
P1 sbit ADDR1=^ 1;
Sbit ADDR2=p ^ 2;
Sbit ADDR3 P1=^ 3;
Sbit ENLED=P1 ^ 4;

Unsigned char code LedChar []={
Xa4 xc0 0, 0 xf9, 0, 0, xb0 x99 0, 0 x92, 0 x82, 0 xf8,
X90 0 x80, 0, 0 x88, 0 x83, 0 xc6, xa1 0, 0 x86, 0 x8e
};

Unsigned char LedBuff []={
0 XFF, 0 XFF, 0 XFF, 0 XFF, 0 XFF, 0 XFF
};

Unsigned int CNT=0;
Unsigned long SEC=999999;
Unsigned char I=0;

Void main ()
{

ENLED=0;
ADDR3=1;
TMOD=0 x10.
TH1=0 XFC;
TL1=0 x67;
TR1=1;
EA=1;
ET1=1;

While (1)
{
If (cnt>
=1000){
CNT=0;
The SEC -;
LedBuff [0]=LedChar [10] the SEC %;
LedBuff [1]=LedChar SEC/10% 10;
LedBuff [2]=LedChar SEC/100% 10;
LedBuff [3]=LedChar SEC/1000% 10;
LedBuff [4]=LedChar SEC/10000% 10;
LedBuff [5]=LedChar SEC/100000% 10;
}
}
}

Void InterruptTimer0 () interrupt 1
{


TH1=0 XFC;
TL1=0 x67;
cnt++;


P0=0 XFF;
The switch (I)
{
Case 0: ADDR2=0; ADDR1=0; ADDR0=0; i++; P0=LedBuff [0]; ENLED=0; break;
Case 1: ADDR2=0; ADDR1=0; ADDR0=1; i++; P0=LedBuff [1]; ENLED=0; break;
Case 2: ADDR2=0; ADDR1=1; ADDR0=0; i++; P0=LedBuff [2]; ENLED=0; break;
Case 3: ADDR2=0; ADDR1=1; ADDR0=1; i++; P0=LedBuff [3]. ENLED=0; break;
Case 4: ADDR2=1; ADDR1=0; ADDR0=0; i++; P0=LedBuff [4]; ENLED=0; break;
Case 5: ADDR2=1; ADDR1=0; ADDR0=1; i=0; P0=LedBuff [5]; ENLED=0; break;
Default: break;
}
}

CodePudding user response:

Appeal for help for help don't sink sink don't sink

CodePudding user response:

,,,,,,,,,,,,,,,,

CodePudding user response:

You set the digital tube display

CodePudding user response:

song of wind and rain reference 3 floor response:
did you set the digital tube display

Just don't show,,,,,,,,

CodePudding user response:

Said tell me your digital tube type, a few stitches

CodePudding user response:

If you didn't write the code shown inside the while loop, just data changes inside the code, I see that you write the code shown in the interrupt function, no note you don't know my right analysis

CodePudding user response:

refer to fifth floor song of wind and rain response:
said tell me your digital tube type, a few stitches

Model is not clear, the stitching is 6 (pin)

CodePudding user response:

refer to 6th floor song of wind and rain response:
if you didn't write the code shown inside the while loop, just data changes inside the code, I see that you write the code shown in the interrupt function, no note you don't know if my analysis of right

But with T0 timer is normal, I suspect the TMOD has a problem,

CodePudding user response:

if you interrupt is wrong, interrupt 1 is T0 interrupt, T1 interrupt should be interrupt. 3

CodePudding user response:

Interrupt 0: external interrupt 0
Interrupt 1:0 timer interrupt
Interrupt 2: external interrupt 1
Interruption of timer interrupt 3:1
Interrupt 4: a serial port interrupt

CodePudding user response:

The
references to the tenth floor song of wind and rain response:
interrupt 0: external interrupt 0
Interrupt 1:0 timer interrupt
Interrupt 2: external interrupt 1
Interruption of timer interrupt 3:1
Interrupt 4: a serial port interrupt

On the right! I read a books try the yes  , thank you very much!

CodePudding user response:

I am novice, is also a flip notes to understand
  • Related