- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
I bought CYW943907AEVAL1F.
I have to connect I2C interface (I use I2C_0 : pins 23, 25 of J6)
with intelligent battery that uses SMBus.
I have to read Battery Voltage.
For read the Battery Voltage I have to write a specific "command_code" and the read two words.
The Battery I2C address is 0001 011 ,
the "command_code" for read Voltage is 0x09 in mV.
The datasheet of the intelligent Battery states that you can read Word in this way
I write this routine :
/* i2c battery */
wiced_i2c_device_t i2c_battery;
/* setup 'i2c_battery' params */
i2c_battery.port = WICED_I2C_1;
i2c_battery.speed_mode = I2C_STANDARD_SPEED_MODE;
i2c_battery.flags = I2C_DEVICE_USE_DMA;
i2c_battery.address = 0x16 >> 1; // 0001 011 Smart Battery Data Specification V1.1 December 1998
i2c_battery.address_width = I2C_ADDRESS_WIDTH_7BIT;
/* init 'i2c_battery' i2c */
status = wiced_i2c_init ( &i2c_battery );
if ( status != WICED_SUCCESS )
{
WPRINT_APP_INFO( ("wiced_i2c_init 'i2c_battery' failed, status = %d\n", status) );
return;
}
uint8_t command_code = 0x09;
/* write command_code */
wiced_result = wiced_i2c_write ( &i2c_battery, WICED_I2C_START_FLAG, (void*)&command_code, 1U );
if ( wiced_result != WICED_SUCCESS )
{
WPRINT_APP_INFO( ("[##] wiced_i2c_write failed, status = %d\n", (int)wiced_result) );
return wiced_result;
}
/* read word */
wiced_result = wiced_i2c_read ( &i2c_battery, WICED_I2C_REPEATED_START_FLAG, (void*)&word, 2U );
if ( wiced_result != WICED_SUCCESS )
{
WPRINT_APP_INFO( ("[##] wiced_i2c_read failed, status = %d\n", (int)wiced_result) );
return wiced_result;
}
The code does't work because wiced_i2c_write fails with result 4 (WICED_ERROR).
The signals that I observe with scope are ...
What I'm wrong ?
The battery responds ACK for the Write command_code ...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, I solved the problem.
I downgrade I2C clock to I2C_LOW_SPEED_MODE.
Battery specification states max 100kHz of clock.