This is the first time I have had a play with any I2C devices and I am stuck.
All I want to do is display the Secs and minutes to the UART line and see the change on the UART Terminal
I am using a PIC18F452
Below is part of the code
Code: Select all
I2C1_Init(100000);
I2C1_Start();
I2C1_Wr(0xD0);
I2C1_Wr(0x00); // Start at REG 3 - Day of week
I2C1_Start();
I2C1_Wr(0xD1);
sec= (I2C1_Rd(1) & 0x7F);
mins= (I2C1_Rd(1) & 0x7F);
hr= (I2C1_Rd(1) & 0x3F);
dow= (I2C1_Rd(1) & 0x7F); // REG 3
day= (I2C1_Rd(1) & 0x3F); // REG 4
mth= (I2C1_Rd(1) & 0x1F); // REG 5
year= (I2C1_Rd(0)); // REG 6
I2C1_Stop();
UART1_Write(sec);
delay_ms(100);
UART1_Write(mins);
delay_ms(100);