Possible bug in i2c_lld_master_transmit_timeout

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
crthorne
Posts: 2
Joined: Fri Oct 07, 2016 5:33 pm

Possible bug in i2c_lld_master_transmit_timeout

Postby crthorne » Fri Oct 07, 2016 5:52 pm

I'm running on STM32F405xx.
ChibiOS 16.1.5 download.
I believe there may be a bug in the function i2c_lld_master_transmit_timeout.
When there are no I2C devices connected - perhaps they are powered down, or have failed, then there is an infinite timeout:

Line 823 in os/hal/ports/STM32/LLD/I2Cv1/I2c_lld.c

/* Calculating the time window for the timeout on the busy bus condition.*/
start = osalOsGetSystemTimeX();
end = start + OSAL_MS2ST(STM32_I2C_BUSY_TIMEOUT);

/* Waits until BUSY flag is reset or, alternatively, for a timeout
condition.*/
while (true) {
osalSysLock();

/* If the bus is not busy then the operation can continue, note, the
loop is exited in the locked state.*/
if (!(dp->SR2 & I2C_SR2_BUSY) && !(dp->CR1 & I2C_CR1_STOP))
break;

/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalOsIsTimeWithinX(osalOsGetSystemTimeX(), start, end))
return MSG_TIMEOUT;

osalSysUnlock();
}


With the timeout check inside the osalSysLock/Unlock the ch.vtlist.vt_systime never gets to change.

i2cMasterTransmitTimeout function is called during initialization, after halInit and chSysInit, i2cStart, etc. but before my other threads have been created.

Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 9 guests