#include <90s8535.h> #include #include // Alphanumeric LCD Module functions #asm .equ __lcd_port=0x15 #endasm #include unsigned char zehntelsek, sekunden, minuten, stunden,i; interrupt [TIM1_OVF] void timer1_ovf_isr(void) { PORTB = ~PORTB; if (zehntelsek < 9) ++zehntelsek; else { zehntelsek = 0; if (sekunden < 59) ++sekunden; else { sekunden = 0; if (minuten < 59) ++minuten; else { minuten = 0; if (stunden < 23) ++stunden; else { stunden = 0; } } } } } void main(void) { // Declare your local variables here char text[16]; // Input/Output Ports initialization // Port A PORTA=0x00; DDRA=0x00; // Port B PORTB=0x00; DDRB=0xFF; // Port C PORTC=0x00; DDRC=0x00; // Port D PORTD=0x00; DDRD=0x00; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Output Compare // OC0 output: Disconnected TCCR0=0x00; TCNT0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: 7,813 kHz // Mode: 10 bit Pulse Width Modulation // OC1A output: Non-Inv. // OC1B output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge TCCR1A=0x00; TCCR1B=0x0B; TCNT1H=0xAA; TCNT1L=0xAA; OCR1AH=0x33; OCR1AL=0x33; OCR1BH=0x33; OCR1BL=0x33; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer 2 Stopped // Mode: Output Compare // OC2 output: Disconnected TCCR2=0x00; ASSR=0x00; TCNT2=0x00; OCR2=0x00; // External Interrupt(s) initialization // INT0: Off // INT1: Off GIFR=0x00; MCUCR=0x00; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x04; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; // LCD module initialization lcd_init(16); #asm("sei") while (1) { sprintf(text," %2u.%2u.%2u.%2u",stunden,minuten,sekunden,zehntelsek); lcd_gotoxy(0,1); lcd_puts(text); }; }