AnsweredAssumed Answered

I2C

Question asked by loeffel.raphael on Oct 18, 2017
Latest reply on Oct 20, 2017 by loeffel.raphael

Hi

 

I'm using I2C1 periphery of a STM32F205 device in master mode. The firmware is based on the HAL V1.2.1 driver with interrupt approach. Three slaves are attached to the bus and 7bit address mode is used. 

 

I'm able to communicate with two slave devices but the communication with the third device fails. I following sequence could be observed within the "HAL_I2C_EV_IRQHandler()" handler:

 

Valid sequence:

1. SB bit was set (Start send)

2. ADDR bit was set (Slave address send)

 

Void seqence:

1. SB bit was set (Start send)

2. ADD10 bit was set (First byte of 10bit address send) -> Should be ADDR

   

The communication fails because the ADD10 bit of the I2C_SR1 got set instead of the ADDR bit. 7bit mode is still configured I2C_OAR1= 0x4000. The obvious difference within the code is the slave address which is 0xF0 for the device which fails and 0xEC and 0x90 for the other ones.   

 

Has someone any idea why the I2C master rise a ADD10 interrupt instead of the ADDR? The only difference within the code is the slave address which is 0xF0 for the device which fails and 0xEC and 0x90 for the other ones.   

 

The I2C initialization code generated by cube is:

/* I2C1 init function */
void MX_I2C1_Init(void)
{
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 400000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}

Start of transfer is:
// Send the byte stream by ISR
if ( HAL_OK == HAL_I2C_Master_Transmit_IT( ptrToHandle, ptrToStreamTx->addr, ptrToStreamTx->ptrToData, ptrToStreamTx->size ) ) {

Outcomes