Hi Sérgio,
Bit 7 of the hour register indicates if the device is in 12 or 24 hour mode. Also Bit 6 is the am/pm indicator, if in 12hour mode. They should be masked out to display a valid hour reading.
H = H & %00111111 ' Mask out hour mode flags
Of course, that doesn't explain why it changes all of the sudden. It should power up in the 24 hour mode, bit7=0. Here's a couple things to think about.
The CONTROL byte of the I2CREAD command should always have a 0 in the lowest bit. Yours is set to 1. So, instead of %10100001, it should be 10100000. PBP automaticaly sets that bit depending on whether it's a read or a write, but in the manual, it states that this bit "should be kept clear"
The PCF8583 is a 100khz device. If your OSC speed is greater than 8mhz you may need to use DEFINE I2C_SLOW 1
HTH,
Darrel
Bookmarks