-For the read operation, the I2C slave address passed in EZUSB_ReadI2C() should be that of the slave device and not the internal register address.
-Could you kindly attach a capture showing the I2C bus lines when getBatteryInfo() function is called? This will confirm the I2CPckt.status value since the EZUSB_WriteI2C() function checks for each of those values in the while loop and sets the return value accordingly.
thanks for you answer.
1. yes it is a mistake, however it does not reach that line of code, becasue if i delete this line, it still does not return the EZUSB_WriteI2C function.
the image is attached (sorry for the bad quality). I see that the clcok signal stay in 0. What could be the problem?
It looks like the ACK is recevied from the slave, however the cypress does not send the data (regist. address) to the slave. It looks like the interrupt does not work and does not send the data to slave. What could be the problem? How should I set up the I2C interrupt? OR what is the problem?
Thanks for you help,
Probably I found the problem.
Since getBatteryInfo() is called from ISR_Ep1out interrupt, I2C interrupt cannot interrupt ISR_Ep1out interrupt to send the data via I2C.
If I call getBatteryFunciton from TD_Poll, it works properly
I was, in the past, forced to modify the source code of the EZUSB lib.
The code "void i2c_isr (void) interrupt I2C_VECT" did not contain a default case.
I introduced a general error and changed the functions EZUSB_ReadI2C and EZUSB_WriteI2C.
If that can help you...
EzUSBLib2.zip 37.4 K