Problems communicating with the PCF85363A RTC Device?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Problems communicating with the PCF85363A RTC Device?

跳至解决方案
3,334 次查看
puddletowntom
Contributor III

I m trying to talk to the PCF85363A RTC device from NXP. I m using an alternative microcontroller to NXP to communicate over the I2C bus. I m expecting to see an ACK after I send it a simple 7-bit slave address however I m not getting any response back. Basically the slave address is 1010001 (0x51). This address is bitshifted to the left by 1 which is 10100010 (0xA2). When I send this to the the I2C bus i was expecting to see the ACK bit set low but as you can see in the picture the last pulse (in yellow) is unexpected because the ACK bit is detected high. Trying this with the value 0x51 on its own is not getting a response back either? Have I defined the slave address in the correct way? If no, could it be a hardware problem?

 scope_31.pngI have attached the code below and the scope grab. 

int main (void)
{
    ADI_I2C_DEV_HANDLE hDevice;
    uint16_t slaveID = 0xA2;   //0x51<<1
    uint32_t secReg = 0x00;

    /* the "usable" buffers within the overallocated buffers housing the guard data */
    uint8_t myBuf[128];
    uint16_t buf_size = 128;

    uint16_t bytesRemaining, bytecount;
    SystemInit();
    test_Init();

    SetSystemClockDivider(ADI_SYS_CLOCK_PCLK, 16);
    SetSystemClockDivider(ADI_SYS_CLOCK_CORE, 16);

    adi_I2C_MasterInit(ADI_I2C_DEVID_0, &hDevice);
    adi_I2C_RegisterCallback(hDevice, cbHandler, hDevice);
    adi_initpinmux();
    adi_I2C_SetMasterClock(hDevice, MASTER_CLOCK);
    adi_I2C_SetBlockingMode(hDevice, false);

    adi_I2C_MasterTransmit(hDevice, slaveID, secReg, 4, myBuf, buf_size, false);

    adi_I2C_UnInit(hDevice);
}
标记 (4)
0 项奖励
回复
1 解答
2,986 次查看
AldoG
NXP TechSupport
NXP TechSupport

Hi Ronan,

I just noticed that you have I2CSCL to the SDA pin, and I2CSD to the SCL pin,

this could be the reason of the no-acknowledge of the device.

Regards,

Aldo.

在原帖中查看解决方案

0 项奖励
回复
11 回复数
2,986 次查看
AldoG
NXP TechSupport
NXP TechSupport

Hi Ronan,

It seems that the slave address you're sending isn't the correct one,

this regarding the image that you share, as I can see the address send by your device 

is 0x44 instead of the expected 0xA2, that's why the ACK bit is high,

when the slave address isn't recognized by the slave, the slave pulls SDA high, meaning a no acknowledge (NACK).

Regards, 

Aldo.

0 项奖励
回复
2,986 次查看
puddletowntom
Contributor III

Hi Aldo,

I think the transmit function on the analog devices side is putting in a read/write bit automatically so I tried bitshifting the 0xA2. The result on the scope seems to show the 0xA2 but still no ACK shown low.

scope_32.png

0 项奖励
回复
2,986 次查看
AldoG
NXP TechSupport
NXP TechSupport

Hi Ronan,

Could you share with me the value of VDD of the PCF85363?

It could be that the SDA/SCL lines high level voltage do not reach its appropriate threshold, min = 0.7VDD,

If you could share your schematic would be great.

Thank you!

Regards,

Aldo.

0 项奖励
回复
2,986 次查看
puddletowntom
Contributor III

Hi Aldo,

The value of VDD is 2.8V. It appears as though the hardware is ok given that the the clock and data lines are appearing. Thanks

pastedImage_1.png

0 项奖励
回复
2,987 次查看
AldoG
NXP TechSupport
NXP TechSupport

Hi Ronan,

I just noticed that you have I2CSCL to the SDA pin, and I2CSD to the SCL pin,

this could be the reason of the no-acknowledge of the device.

Regards,

Aldo.

0 项奖励
回复
2,986 次查看
puddletowntom
Contributor III

Hi Aldo,

So I managed to switch the I2C lines and I have noticed that whats appearing on the scope seems to be different now. It appears as though the RTC device is showing some kind of ACK, however i m still a little confused. I m not seeing data on the rx buffer. But it seems that for some cases, whats on the scope looks good. I tested running the MasterReceive function for the year value and the second value because I know that the year will be a fixed value and the seconds will be a changing value. When I use the receive function for the year register(0x07) I can the following,

pastedImage_1.png

The reference from the previous record taken in white is the same. When I used the receive function for the seconds register, the reference from the previous measurement changes, shown below. So I m assuming that the RTC is responding. 

pastedImage_1.png

A basic test with the adi_I2C_MasterSlaveLoopback function seems to show that the ACK is low which is as expected. eg 

pastedImage_2.png

I m still trying to figure out why nothing is appearing in my receive buffer. The code to do this was as follows,

int main (void)
{
    ADI_I2C_DEV_HANDLE hDevice;
    uint16_t slaveID = 0x51;
    uint16_t bytesRemaining, bytecount;

    /* Clock initialization */
    SystemInit();

    /* test system initialization */
    test_Init();

     tx[0] = 0x07;
    /* Take HCLK/PCLK down to 1MHz for better power utilization */
    /* Need to set PCLK frequency first, because HCLK frequency */
    /* needs to be greater than or equal to the PCLK frequency  */
    /* at all times.                                            */
    SetSystemClockDivider(ADI_SYS_CLOCK_PCLK, 16);
    SetSystemClockDivider(ADI_SYS_CLOCK_CORE, 16);

    adi_I2C_MasterInit(ADI_I2C_DEVID_0, &hDevice);
     adi_I2C_RegisterCallback(hDevice, cbHandler, hDevice);
    adi_initpinmux();
    adi_I2C_SetMasterClock(hDevice, MASTER_CLOCK);
    adi_I2C_SetBlockingMode(hDevice, false);
    //adi_I2C_MasterSlaveLoopback(hDevice, slaveID, tx, rx, bytecount);
    adi_I2C_MasterReceive(hDevice, slaveID, 0x07, 1, rx, 3, false);
    adi_I2C_UnInit(hDevice);
}

Thanks,

Ronan

0 项奖励
回复
2,986 次查看
puddletowntom
Contributor III

Hi Aldo,

False alarm. I m seeing values in my rx buffer now and they appear to be changing at the rate you would expect for seconds, minutes and hours. I think I ll leave my previous post up there for others to see. Interestingly, I think it was only after I transmitted something once (set the year value) that i started to receive values in the receive buffer.

Thanks for all the help,

Ronan

0 项奖励
回复
2,986 次查看
AldoG
NXP TechSupport
NXP TechSupport

Hi Ronan,

Glad that everything is working now!

Best regards,

Aldo

0 项奖励
回复
2,986 次查看
puddletowntom
Contributor III

Hi Aldo,

I cant believe I didn't see that. Well spotted. I will try again on Monday and let you know if it works.

Thank you very much.

Ronan. 

0 项奖励
回复
2,986 次查看
AldoG
NXP TechSupport
NXP TechSupport

Hi Ronan,

Could you tell me the value of your pull-ups?

Also, does your MCU & pull-ups are conected to the same VDD (2.8V) ?

Thank you.

Regards,

Aldo

0 项奖励
回复
2,986 次查看
puddletowntom
Contributor III

Hi Aldo,

The pull up resistor values are 2.2k for each of the I2C lines. Both the MCU and the RTC are connected to 2.8V.

Thanks,

Ronan

pastedImage_1.png

0 项奖励
回复