или так ( VMLAB 3.11 + WINAVR + ATMEGA8 ) #include <avr\io.h> // Most basic include files #include <avr\interrupt.h> // Add the necessary ones #include <avr\signal.h> // here
unsigned char count=0x00; unsigned char i[8]={0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70}; unsigned char temp=0x00; unsigned char t=0x00; SIGNAL(SIG_OVERFLOW0) { count++; for(t=0;t<8;t++) { if (count<i[t]) temp|=(1<<t); else temp&=~(1<<t); } PORTD=temp; }
int main(void) { DDRD=0xFF; PORTD=0x00; TCNT0=0x00; TCCR0=0x02; TIMSK|=(1<<TOIE0); sei(); while(1) { // Infinite loop; define here the asm("nop"); }
}
|