PSoC5 Freezes during I2C Transmission | Cypress Semiconductor
PSoC5 Freezes during I2C Transmission
We are using 3 PSoCs on our board. We are using CY8C5268AXI-LP047 (PSoC5), CY8C4247AZI-M485 (PSoC4200M) and CY8C4245AXI-483 (PSoC4200).
The PSoC5 is connected to the PC via USBUART and I get to send commands using a hyperterminal. The commands include GPIO write/read. The PSoC4200M (address: 0x0A) and PSoC4200 (address: 0x08) are connected to the PSoC5 via I2C. Whenever I issue a GPIO read/write command in the hyperterminal, the PSoC5 will return ^OK or ^ERROR for GPIO Write and ^LOW or ^HIGH for GPIO read.
In the hardware, we had incorporated an LED which serves as the heartbeat of PSoC5. Using Systick timer, the LED is set to toggle every 1 second. This indicates that the PSoC5 is fully operational.
For the debugging of our board, I did a modular testing with the following flow:
1. PSoC5 Test - Issue GPIO Read/Write Command via I2C to read/write to PSoC5 GPIO. USB comm is ok and result is as expected.
2. PSoC5 and PSoC4200M Test - Issue GPIO Read/Write Command via I2C to read/write to PSoC4200M GPIO. USB comm is ok. I2C comm is ok. Result is as expected.
3. PSoC5, PSoC4200M and PSoC4200 Test - Issue GPIO Read/Write Command via I2C to read/write to PSoC4200 GPIO. Error received. PSoC5 hangs. PSoC5 LED does not toggle.
The I2C code for the I2C slaves are identical. I was not expecting an error for the PSoC5, PSoC4200M and PSoC4200 Test. I did some debugging and included multiple printfs in the PSoC5 I2C Write. See code excerpt below:
void I2C_Master_Write(uint8 SlaveAddress, int i)
USB_printf("\r\nMaster I2C Write attempt...\r\n");
if (0u == WriteCommandPacket(SlaveAddress, i))
USB_printf("\r\nMaster Write I2C attempt success\r\n");
/* Read response packet from the slave */
USB_printf("\r\nMaster Read I2C attempt\r\n");
if (0u == ReadStatusPacket(SlaveAddress))
USB_printf("\r\nMaster Read I2C attempt successful\r\n");
USB_printf("Error Reading Buffer!");
USB_printf("\r\nMaster Write I2C attempt fail\r\n");
uint32 WriteCommandPacket(uint8 SlaveAddress, int i)
uint32 status = TRANSFER_ERROR;
write_err = DFE_I2C_MasterWriteBuf(SlaveAddress, dfe_i2cbufw, i, DFE_I2C_MODE_COMPLETE_XFER);
sprintf((char *) res, "\r\n%u Error in DFE Master Write\r\n", write_err);
while (0u == (DFE_I2C_MasterStatus() & DFE_I2C_MSTAT_WR_CMPLT))
/* Displays transfer status */
if (0u == (DFE_I2C_MSTAT_ERR_XFER & DFE_I2C_MasterStatus()))
/* Check if all bytes was written */
if (DFE_I2C_MasterGetWriteBufSize() == i)
status = TRANSFER_CMPLT;
USB_printf("\r\nDFE_I2C_MasterStatus() = %u\r\n", DFE_I2C_MasterStatus());
sprintf((char *)res, "\r\n write command status: %lu\r\n", status);
I've attached an image of the PSoC5 response to the hyperterminal.
The I2C_MasterWriteBuf() API returns 0 errors.
I2C_MasterStatus() API returns 162 thus the WriteCommandPacket returns 0xFF or 255. I am expecting that after printing the message "write command status: 255" in the hyperterminal, it should immediately be followed by "Master Write I2C attempt fail" however the PSoC5 freezes and I need to power cycle the whole board to unfreeze the PSoC5.
I've worked on this issue for quite some time now and I'm still stuck. Can anyone indicate what may be wrong or what I've missed? Also, I cannot provide directly the project zip file in the forum as it is not approved by our client. I can, however, forward a copy of the projects via email (firstname.lastname@example.org) for anyone who can help.