// vim:ts=4 // // fl9999.c 2003.07.07 runner@protom.org // // avr-gcc -mmcu=at90s8535 -Wa,-ahlms=fl9999.lst -o fl9999.elf fl9999.c // avr-objcopy -O ihex fl9999.elf fl9999.hex #include #include #include #include #define sleep() ({ asm volatile ("sleep" "\n"); }) static uint16_t counter; // output data uint8_t SEG[] = { 0x3f, // 0 0x06, // 1 0x5b, // 2 0x4f, // 3 0x66, // 4 0x6d, // 5 0x7d, // 6 0x2f, // 7 0x7f, // 8 0x6f, // 9 }; /* * 10MHz / 1024 / 256 = 38Hz */ SIGNAL(SIG_OVERFLOW0) { outp(SEG[(counter%10000)/1000], PORTA); outp(SEG[(counter%1000)/100], PORTB); outp(SEG[(counter%100)/10], PORTC); outp(SEG[counter%10], PORTD); counter++; } int main (void) { outp(0xff, DDRA); // Set PORTA is OUTPUT Mode outp(0xff, DDRB); // Set PORTB is OUTPUT Mode outp(0xff, DDRC); // Set PORTC is OUTPUT Mode outp(0xff, DDRD); // Set PORTD is OUTPUT Mode outp((1<