cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 I2C HAL_TIMEOUT ERROR

fatih yavuzy?lmaz
Associate II
Posted on April 03, 2018 at 15:25

I'm new for STM32 family. I use STM32 nucleo64 F401RE development  board and Keil5 with STM32CubeMX for software. I have problem about sending data with I2C. the slave IC has 4 register group. the each group register has different address and 31 register. 1. group register slave address is F0, 2

. group register slave address is F4,

3. group register slave address is F8 and 4. group register slave address is FC,

If I send  data to register group F8 or FC I can send all data (address +register addres+data0+data1.....+data30) every time.

If I send data to register group F0 or F4 I can not send data. I have HAL_TIMEOUT error during send slave address. Even if the slave IC send acknowledge. 

I have this problem in

static HAL_StatusTypeDef I2C_WaitOnMasterAddressFlagUntilTimeout(I2C_HandleTypeDef *hi2c, uint32_t Flag, uint32_t Timeout, uint32_t Tickstart)

{

while(__HAL_I2C_GET_FLAG(hi2c, Flag) == RESET)

{

if(__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_AF) == SET)

{

/* Generate Stop */

hi2c->Instance->CR1 |= I2C_CR1_STOP;

/* Clear AF Flag */

__HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_AF);

hi2c->ErrorCode = HAL_I2C_ERROR_AF;

hi2c->PreviousState = I2C_STATE_NONE;

hi2c->State= HAL_I2C_STATE_READY;

/* Process Unlocked */

__HAL_UNLOCK(hi2c);

return HAL_ERROR;

}

/* Check for the Timeout */

if(Timeout != HAL_MAX_DELAY)

{

if((Timeout == 0U)||((HAL_GetTick() - Tickstart ) > Timeout))

{

hi2c->PreviousState = I2C_STATE_NONE;

hi2c->State= HAL_I2C_STATE_READY;

/* Process Unlocked */

__HAL_UNLOCK(hi2c);

return HAL_TIMEOUT;

}

}

}

return HAL_OK;

 

when I debug software, if I send data to F8 or FC  __HAL_I2C_GET_FLAG(hi2c, Flag) return 1 

and I can send all data

but if I send data to F0 or F4  __HAL_I2C_GET_FLAG(hi2c, Flag) return 0 

and I can not send data I have HAL_TIMEOUT error

NOTE: when I check signals with oscilloscope and logic analyzer there are no any different 

             addres sending sequence when I send F0,F4 or F8,FC.

NOTE: when I use another company development board I can send data to all register group

I couldnt find any reason even if I spend too much time and search.

I need to help to solve this problem  

thanks

fatih

#i2c-hal_timeout-error
1 REPLY 1

Sorry, bumping old zombie unanswered threads off my feed

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..