Professional Documents
Culture Documents
New Ex 3
New Ex 3
{
P0=0;
P1=0;
TF1_bit = 0; // Ensure that Timer1 interrupt flag is cleared
ET1_bit = 1; // Enable Timer1 interrupt
EA_bit = 1; // Set global interrupt enable
GATE1_bit = 0; // Clear this flag to enable Timer1 whenever TR1 bit is set.
C_T1_bit = 0; // Set Timer opera on: Timer1 counts the divided-down systam
clock.
M11_bit = 0; // M11_M01 = 01 => Mode 1(16-bit Timer/Counter)
M01_bit = 1;
TR1_bit = 0; // Turn off Timer1
TH1 = TH1_INIT; // Set Timer1 high byte
TL1 = TL1_INIT; // Set Timer1 low byte
TR1_bit = 1; // Run Timer1
P0=0x88;
P1=0x01;
return ;
}
{
P0=0;
P1=0;
TF1_bit = 0; // Ensure that Timer1 interrupt flag is cleared
ET1_bit = 1; // Enable Timer1 interrupt
EA_bit = 1; // Set global interrupt enable
GATE1_bit = 0; // Clear this flag to enable Timer1 whenever TR1 bit is set.
C_T1_bit = 0; // Set Timer opera on: Timer1 counts the divided-down systam
clock.
M11_bit = 0; // M11_M01 = 01 => Mode 1(16-bit Timer/Counter)
M01_bit = 1;
TR1_bit = 0; // Turn off Timer1
TH1 = TH1_INIT; // Set Timer1 high byte
TL1 = TL1_INIT; // Set Timer1 low byte
TR1_bit = 1; // Run Timer1
P0=0x86;
P1=0x08;
return ;
}
It can be seen that to display any single digit number from 0 to 9 in binary or
letters from A to F in hexadecimal, we would require seven separate segment
connections plus one additional connection for the LED’s “common”
connection.