cancel
Showing results for 
Search instead for 
Did you mean: 

SMBUS packets corrupted with HAL_SMBUS_Transmit_IT

Gmampel
Associate

Hi everyone,

I’m debugging an SMBus issue between an STM32H7, an LTC4100 Smart Charger, and an RRC2054 Smart Battery. I’m trying to write to the ChargingVoltage() register (command 0x15), but the SMBus frames captured on the logic analyzer appear corrupted and often contain NACKs or unexpected STOP/START conditions.

My write function is:

 
static HAL_StatusTypeDef SMBUS_WriteWord(PSMBUSDESC pSMBUSDesc,
uint8_t addr,
uint8_t cmd,
uint16_t value)
{
HAL_StatusTypeDef status;
uint8_t buf[3];

buf[0] = cmd;
buf[1] = value & 0xFF; // LSB
buf[2] = (value >> ‌‌ & 0xFF; // MSB

status = HAL_SMBUS_Master_Transmit_IT(
pSMBUSDesc->SMBUSinst,
addr << 1,
buf,
sizeof(buf),
SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC
);

while (HAL_SMBUS_GetState(pSMBUSDesc->SMBUSinst) != HAL_SMBUS_STATE_READY);

return status;
}

The function returns HAL_OK, so the STM32 believes the transfer is successful.
However, the logic analyzer shows clearly invalid SMBus traffic. These are examples of what I see when calling:

SMBUS_WriteWord(pSMBUSDesc, CHARGER_ADDR, CHARGING_VOLTAGE, 1023);

Examples of captured sequences:

 

if(SMBUS_WriteWord(pSMBUSDesc, CHARGER_ADDR, CHARGING_VOLTAGE, 1023)!= HAL_OK) { are :
Stop Start Stop 00010001 ACK 0000 Stop 10100101 NACK 11111101 ACK 00100 Stop 010
Stop Start 00010010 ACK 00010011 Stop 10111111 NACK 101 Stop Stop 1000010
Stop Start Stop 00001001 ACK 00 Stop 0101 Stop 10010111 NACK 11110100 ACK 1000010
 

The logic analyzer setup seems correct, and the corruption is consistent across multiple captures.

I have tried different transfer sizes and XferOptions, but nothing changes the behaviour.

Has anyone seen this behavior with the STM32H7 SMBus HAL or with the LTC4100?
Any ideas on what could cause these malformed frames would be greatly appreciated.

Thanks!

Post edited by ST moderator to be inline with community rules for code sharing. Please see the article How to insert source code - STMicroelectronics Community

1 REPLY 1
Saket_Om
ST Employee

Hello @Gmampel 

Please ensure 4.7kΩ (typical) pull-ups resistors on both SDA and SCL line.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om