PCF8563 RTC gives i2c Fail

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PCF8563 RTC gives i2c Fail

Jump to solution
2,068 Views
AL_AM
Contributor I

Hello, I'm using a custom board that contains 5 i2c sensors. The i2c Bus works fine. the pull-up resistors are included and when I use the I2C tool to detect the i2c connected sensors I get the following:

AL_AM_0-1613341967019.png

 

 

The above image shows that the RTC has the address 0x00 while in the datasheet of the PCF8563 it has 2 addresses depends on the read-write operation.

AL_AM_1-1613341967034.png

 

Does this mean that the RTC is not working

 

the address 0x00 is the only unknown address for me.

 

if it is working then, when I tried to follow the  User-guide_UM10301 exactly on page 27 where there is an example of how to set the PCF8563:

AL_AM_2-1613341967035.png

 

I always get an error in the i2c. my code is as follows:

(I use the ESP32 with the esspressif-idf )

AL_AM_3-1613341967037.png

        i2c_master_start(CMD);
        i2c_master_write_byte(CMD, RTC_Write_Add, Want_Ack);
        i2c_master_write_byte(CMD, control_status_1, Want_Ack);
        i2c_master_write_byte(CMD, 0x00, Want_Ack);
        i2c_master_write_byte(CMD, 0x00, Want_Ack);
        i2c_master_write_byte(CMD, VL_secondsReg, Want_Ack);
        i2c_master_write_byte(CMD, 0x00, Want_Ack);        // Vl Sec 00
        i2c_master_write_byte(CMD, 0x45, Want_Ack);        // Min 45
        i2c_master_write_byte(CMD, 0x19, Want_Ack);        // Hou 7 PM
        i2c_master_write_byte(CMD, 0x12, Want_Ack);        // Days 12
        i2c_master_write_byte(CMD, 0x05, Want_Ack);        // Fri
        i2c_master_write_byte(CMD, 0x82, Want_Ack);        // set month 
        i2c_master_write_byte(CMD, 0x21, Want_Ack);        // 2021
        i2c_master_stop(CMD);
        ESP_ERROR_CHECK(i2c_master_cmd_begin(I2C_NUM_0, CMD, 1000 / portTICK_RATE_MS));

Summarizing my questions:

 

1- The appearance of the address 0x00 (which is the Control_status_1 Register) as the chip address is ok

2- if it's ok, then what could be my issue

 

 

 

0 Kudos
1 Solution
2,048 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hello Amir,

The 7-bit slave address of the PCF8563 is 0x51 followed by a write (0) or read (1) bit. This results in 0xA2 for a write as shown in the datasheet.

The second byte is the address of the register you want to write to. In your case Control_status_1 (0x00).

The third byte is the data you want to write to the register. In your case 0x00.

Then you can either send a stop condition or continue sending next bytes as the PCF8563 support auto incrementing of the register address.

Capture.JPG

It might be useful to use a logic analyzer or an oscilloscope to check what is going on the bus.

Best regards,

Tomas

 

View solution in original post

3 Replies
849 Views
lockie
Contributor I

I am using the pfc8563 in 4 dataloggers running on STM32L152RE. The RTC loses about a second a day, so I wrote a simple arduino program  get the date and time from the internet. This works well for DS3231 RTC but I cannot get the PFC8563 to connect using any ESP processors (ESP32 or ESP8266) and I do not have a spare STM to use. I2c finder running on ESP32 can find the 8563 at 0x51, but the program is unable to set the time on this RTC, but works fine with the DS3231 RTC. Yet using the STM works OK! What could be the issue? I have spent weeks on this and have gotten nowhere. I am using Joe Robertson's library for 856, Rtc_Pfc8563 which others have used and recommended. I am not a programmer so I feel unsure about changing timings if that is the issue.

Thanks

Lockie

0 Kudos
2,030 Views
AL_AM
Contributor I

Thank you Tomas......I found out that the 0x00 that I get on the bus is the ESP Address. while the RTC was missing on the board that I was using. i asked for a replacement.

0 Kudos
2,049 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hello Amir,

The 7-bit slave address of the PCF8563 is 0x51 followed by a write (0) or read (1) bit. This results in 0xA2 for a write as shown in the datasheet.

The second byte is the address of the register you want to write to. In your case Control_status_1 (0x00).

The third byte is the data you want to write to the register. In your case 0x00.

Then you can either send a stop condition or continue sending next bytes as the PCF8563 support auto incrementing of the register address.

Capture.JPG

It might be useful to use a logic analyzer or an oscilloscope to check what is going on the bus.

Best regards,

Tomas