# Contains? & ltIOM 16v . h & gt;
# Contains? & ltmacros.h & gt
# Definition? Ucal? Not signed? tea
# Definition? uint? Not signed? Internationalorganizations (same as international organizations)
Ucal? led_7[ 10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F };
Ucal? position[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0x Fe };
Ucal? dis _ buff[8]; //? The display buffer is used for storing the segment code value of 8 characters to be displayed.
Ucal? Hypothesis;
Ucal? time_ 1ms_ok,display _ ok = 0;
Ucal? time0_old,time0_new,freq _ time
uint? freq
Invalid? Show (void)//? Dynamic scanning function of 8-bit LED digital tube
{?
PORTA? =? 0xff
PORTC? =? led _ 7[dis _ buff[posit]];
What if? (posit==5)?
PORTC? =? PORTC? |? 0x80?
PORTA? =? Location; ?
What if? (++posit? & gt=8? )?
Hypothetically? =? 0;
}
//? Timer? 2? Output? Compare? Interrupt? Service? routine
#pragma? Interrupt handler? Timer2 _ ISR: 4
Invalid? Timer2 _ ISR (invalid)
{
time0_new? =? TCNT0? //? 1ms records the current count value of T/C0.
time_ 1ms_ok? =? 1;
Show _ok? =? ~ display _ ok
What if? (display normal)
Display ();
}
Invalid? freq_to_disbuff(void)//? Convert the frequency value into BCD code and send it to the display buffer.
{
Ucal? I,j = 7;
For what? (I = 0; I < = 4; i++)
{
dis_buff[j-i]? =? freq? %? 10;
freq? =? freq? /? 10;
}
dis_buff[2]? =? freq
}
Invalid? Major (invalid)
{
Not signed? Charles? Me;
DDRA = 0x ff; ? //? LED digital tube drive
DDRC = 0x ff;
//? T/C0 initialization, external counting mode
TCCR0 = 0x06? //? External T0 pin falling edge trigger count, normal mode
TCNT0 = 0x00
OCR0 = 0x00
//? T/C2 initialization
TCCR2 = 0x0B? //? Internal clock, frequency division of 32 (4M/32= 125KHz), CTC mode.
TCNT2 = 0x00
OCR2 = 0x7C? //? OCR2? =? 0x7C( 124), (124+1)125 =1millisecond.
TIMSK = 0x80//? Allow T/C2 comparison matching interrupt
For what? (I = 0; I < = 7; i++)? dis_buff[i]? =? 0;
Time 0 _ Old? =? 0;
ASM(“sei”); ? //? Open global interrupt
What time? ( 1)
{
What if? (time _ 1 ms _ok)
{? //? Cumulative T/C0 count value
What if? (time0_new? & gt=? time0_old)? freq? =? freq? +? (time0_new? -? time 0 _ old);
Or what? freq? =? freq? +? (256? -? Time 0 _ Old? +? time 0 _ new);
Time 0 _ Old? =? time0 _ new
What if? (++freq_time? & gt=? 100)
{
freq_time? =? 0; ? //? 100 ms to,
freq _ to _ disbuff(); //? Send pulse count value display in100 ms.
freq? =? 0;
}?
time_ 1ms_ok? =? 0;
}
}
}
Guangzhou 1997- 1998 is prosperous. East Lake, North Park, South Park and Panxi have their own characteristics, and f