//********************************************************************** /* <RTCのテストデータ送信用(マスター)> */ //********************************************************************** #define ACK 1 #define NO_ACK 0 //********************************************************************** void main() { static unsigned short cnt, hh, mm, ss; static char buf[8]; // OSCCON = 0b01110000; // クロックを8Mhzに設定する。 ANSEL = 0b00000000; // A/D変換は使用しない。 TRISA = 0b00110000; TRISB = 0b00001111; // Lcd_Custom_Config(&PORTA, 1, 0, 7, 6, &PORTB, 5, 6, 7); Lcd_Custom_Cmd(LCD_CURSOR_OFF); Lcd_Custom_Cmd(LCD_CLEAR); // for (cnt = 0; cnt < 16; cnt++) { Lcd_Custom_Chr(1, cnt + 1, 0xFF); Delay_ms(50); } for (cnt = 0; cnt < 16; cnt++) { Lcd_Custom_Chr(2, cnt + 1, 0xFF); Delay_ms(50); } Lcd_Custom_Cmd(LCD_CLEAR); // // Soft_I2C_Config(&PORTA, 2, 3); // SDA, SCL // while (1) { // Soft_I2C_Start(); Soft_I2C_Write(0x80); Soft_I2C_Write(0x00); Soft_I2C_Start(); Soft_I2C_Write(0x81); hh = Soft_I2C_Read(ACK); mm = Soft_I2C_Read(ACK); ss = Soft_I2C_Read(NO_ACK); Soft_I2C_Stop(); // ByteToStr(hh, buf); buf[1] = buf[1] == ' ' ? '0' : buf[1]; Lcd_Custom_Out(1, 1, &buf[1]); Lcd_Custom_Chr(1, 3, ':'); ByteToStr(mm, buf); buf[1] = buf[1] == ' ' ? '0' : buf[1]; Lcd_Custom_Out(1, 4, &buf[1]); Lcd_Custom_Chr(1, 6, ':'); ByteToStr(ss, buf); buf[1] = buf[1] == ' ' ? '0' : buf[1]; Lcd_Custom_Out(1, 7, &buf[1]); // if (PORTB.F3 == 0) { //時刻設定 Soft_I2C_Start(); Soft_I2C_Write(0x80); Soft_I2C_Write(0x03); Soft_I2C_Write(12); //12時 Soft_I2C_Write(34); //34分 Soft_I2C_Write(56); //56秒 Soft_I2C_Write(0x01); //設定指示 Soft_I2C_Stop(); } // Delay_ms(100); } } //**********************************************************************