P1 = TH0; //TH0 is the high byte of the measured value
}
void main()
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
AUXR = 0x80; //1T mode
TMOD = 0x08; //Enable GATE, and enable timing when INT0 is 1
TL0 = 0x00;
TH0 = 0x00;
while (INT0); //Wait for INT0 to be low
TR0 = 1; //Start timer
IT0 = 1; //Enable INT0 falling edge interrupt
EX0 = 1;
EA = 1;
while (1);
}
Assembly code
;Operating frequency for test is 11.0592MHz
AUXR DATA 8EH
P0M1 DATA 093H
P0M0 DATA 094H
P1M1 DATA 091H
P1M0 DATA 092H
P2M1 DATA 095H
P2M0 DATA 096H
P3M1 DATA 0B1H
P3M0 DATA 0B2H
P4M1 DATA 0B3H
P4M0 DATA 0B4H
P5M1 DATA 0C9H
P5M0 DATA 0CAH
ORG 0000H
LJMP MAIN
ORG 0003H
LJMP INT0ISR
ORG 0100H
INT0ISR:
MOV P0,TL0 ;TL0 is the low byte of the measured value
MOV P1,TH0 ;TH0 is the high byte of the measured value