- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using the Cypress EZ-USB FX2LP board and have created firmware to allow it to read data from an I2C based slave device and I am trying but cannot read the correct data from the slave device. Any guidance on the matter would be greatly appreciated !!
Please find the attachment. I2C command of slave device
STA = I2C start with address and R/W bit
The default address for I2C is 0x73 (115, or hexadecimal 73H), as the most-significant 7 bits of the STA byte. Therefore the default STA byte is 230 (0xE6) for a write, and 231 (0xE7) for a read.
Here is my code:
switch(VR){
case VR_GET_DEVICE_TEMPERATURE:
EP0BUF[0] = Get_Temperature(&EP0BUF[2]);
EP0BCH = 0x00;
EP0BCL = 0x05;
break;
default:
return(true);
}
unsigned char Get_Temperature(unsigned char *Temperature)
{
unsigned char Status, Success;
Status = 1;
Temperature[0]=0x7A; //Get Temperature command (I2C Command Code)
Temperature[1]=C_lower;
Temperature[2]=C_higher;
/* Get the temperature from the slave device */
Success = EZUSB_WriteI2C(0xE6, 3, (BYTE xdata *) &Temperature[0]);
Status &= Success;
EZUSB_Delay(1);
Success = EZUSB_ReadI2C(0xE7, 5, (BYTE xdata *) &Temperature[0]);
Status &= Success;
EZUSB_Delay(1);
return Status;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
In the EZUSB_WriteI2C and EZUSB_ReadI2C functions please pass the 7-bit slave address (0x73) as the first parameter. The functions will take care of shifting the address bits and adding the read/write bit as the LSB. Please implement this and check if it returns the correct data.
Also, please provide the I2C slave datasheet and also the the data currently being read from the slave device.
Thanks,
Yatheesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
In the EZUSB_WriteI2C and EZUSB_ReadI2C functions please pass the 7-bit slave address (0x73) as the first parameter. The functions will take care of shifting the address bits and adding the read/write bit as the LSB. Please implement this and check if it returns the correct data.
Also, please provide the I2C slave datasheet and also the the data currently being read from the slave device.
Thanks,
Yatheesh