Написал на скорую руку ( VMLAB + 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]; unsigned char temp=0x00; SIGNAL(SIG_OVERFLOW0) { count++; if (count<i[0]) temp|=1; else temp&=~1; if (count<i[1]) temp|=2; else temp&=~2; if (count<i[2]) temp|=4; else temp&=~4; if (count<i[3]) temp|=8; else temp&=~8; if (count<i[4]) temp|=16; else temp&=~16; if (count<i[5]) temp|=32; else temp&=~32; if (count<i[6]) temp|=64; else temp&=~64; if (count<i[7]) temp|=128; else temp&=~128;
PORTD=temp; }
int main(void) { DDRD=0xFF; PORTD=0x00; i[0]=0x00; i[1]=0x10; i[2]=0x20; i[3]=0x30; i[4]=0x40; i[5]=0x50; i[6]=0x60; i[7]=0x70; TCNT0=0x00; TCCR0=0x02; TIMSK|=(1<<TOIE0); sei(); while(1) { // Infinite loop; define here the asm("nop"); }
}
|