#define F_CPU 16000000UL #include #include #include #define WADDR 0xA2 #define RADDR 0xA3 void init_display(); void init_timer0(); //void init_timer1(); void init_I2C(); void I2Cstart() {TWCR = (1< I2Cstart(); I2Csend(WADDR); I2Csend(0x0D); // OSCOUT register I2Csend(0x83); // 1 Hz I2Cstop(); I2Cstart(); I2Csend(WADDR); I2Csend(0x02); // seconds register I2Cstart(); // restart I2Csend(RADDR); sec = I2CreadACK(); min = I2CreadACK(); hour = I2CreadNACK(); I2Cstop(); LCDline[0][8] = (hour>>4)+'0'; LCDline[0][9] = (hour&0x0F)+'0'; LCDline[0][11] = (min>>4)+'0'; LCDline[0][12] = (min&0x0F)+'0'; LCDline[0][14] = (sec>>4)+'0'; LCDline[0][15] = (sec&0x0F)+'0'; sei(); // enable global interrupts // loop forever while(1) { PORTB = PINE; //PORTB ^= 0x80; //_delay_ms(500); if(onesec==1) { onesec = 0; PORTB ^= 0x80; } /* I2Cstart(); I2Csend(WADDR); I2Csend(0x02); // seconds register I2Cstart(); // restart I2Csend(RADDR); sec = I2CreadACK(); min = I2CreadACK(); hour = I2CreadNACK(); I2Cstop(); LCDline[0][8] = (hour>>4)+'0'; LCDline[0][9] = (hour&0x0F)+'0'; LCDline[0][11] = (min>>4)+'0'; LCDline[0][12] = (min&0x0F)+'0'; LCDline[0][14] = (sec>>4)+'0'; LCDline[0][15] = (sec&0x0F)+'0'; } */ } // while(1) } void init_display() { DDRA = 0xFF; PORTC &= 0xAF; DDRC |= 0x50; PORTC &= 0xBF; PORTA = 0x38; PORTC |= 0x10; PORTC &= 0xEF; PORTA = 0x0C; PORTC |= 0x10; PORTC &= 0xEF; PORTA = 0x01; PORTC |= 0x10;; PORTC &= 0xEF; _delay_ms(2); } void init_timer0() { TCCR0B |= (1<