// vim:ts=4 // // fl9999a.c 2003.07.07 runner@protom.org // // const data(SEG) on to PROGRAM AREA. // // avr-gcc -mmcu=at90s8535 -Wa,-ahlms=fl9999a.lst -o fl9999.elf fl9999.c // avr-objcopy -O ihex fl9999a.elf fl9999.hex #include #include #include #include #include #define sleep() ({ asm volatile ("sleep" "\n"); }) static uint16_t counter; // output data PROGMEM uint8_t SEG[] = { 0x3f, // 0 0x06, // 1 0x5b, // 2 0x4f, // 3 0x66, // 4 0x6d, // 5 0x7d, // 6 0x2f, // 7 0x7f, // 8 0x6f, // 9 }; /* * 10MHz / 256 / 256 = 152Hz */ SIGNAL(SIG_OVERFLOW0) { outp(PRG_RDB(&SEG[(counter%10000)/1000]), PORTA); outp(PRG_RDB(&SEG[(counter%1000)/100]), PORTB); outp(PRG_RDB(&SEG[(counter%100)/10]), PORTC); outp(PRG_RDB(&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<