Вот и код, конечно извеняюсь за ,может неоптимальность
/*Chip type : ATmega8
Program type : Application
Clock frequency : 4,096000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 256
************************************************** ***/
#include ‹mega8.h›
#include ‹delay.h›
char a;
char b;
char x;
void h(void) //ôóåêöèÿ äëÿ 7 ñåãìåíò èíäèêàòîðà
{
if(x==0)
PORTD=0x40;
if(x==1)
PORTD=0x79;
if(x==2)
PORTD=0x24;
if(x==3)
PORTD=0x30;
if(x==4)
PORTD=0x19;
if(x==5)
PORTD=0x12;
if(x==6)
PORTD=0x02;
if(x==7)
PORTD=0x78;
if(x==
![Горд собой](images/smilies/icon_dovl.gif)
PORTD=0x00;
if(x==9)
PORTD=0x10;
};
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
TCNT0=0xB0;
//----------------------------------
a++;
if(a==0x0A)
{
b++;
a=0;
};
//----------------------------------
if(b==0x14)
{
h();
x++;
a=0;
b=0;
if(x==0x0A)
{
a=0;
b=0;
x=0;
};
};
}
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0xFF;
DDRB=0x00;
// Port C initialization
// Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTC=0x04;
DDRC=0x7F;
// Port D initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTD=0x00;
DDRD=0xFF;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x04;
TCNT0=0xB0;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x01;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
// Global enable interrupts
#asm("sei")
while (1)
{
};
}