AnsweredAssumed Answered

I2C Addr bit not set on 401 Discover Board

Question asked by chu.hiloshi on Apr 20, 2015
Latest reply on Apr 21, 2015 by chu.hiloshi
Hi All,
Please see below I2C protocal:
codecI2C.png

I am using STM32F401 Discover Board, the slave is on board CS43L22, the address is 0x94.

I try to send 0x01 to register 0x02: Single_WriteI2C(0x02,0x01), but only send out address, no data phase. I think it cause by slave not ack.
The low level driver is stm32f4xx_hal_i2c.c, if I using old stm32f4xx_i2c.c, the result is OK. So I do not know what is going on.

The complete code as below:
void I2C1_Init()
{


     __GPIOB_CLK_ENABLE();
     GPIO_InitStruct.Pin = GPIO_PIN_6;
     GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;                    //GPIO_MODE_OUTPUT_PP
     GPIO_InitStruct.Pull = GPIO_NOPULL;                         //GPIO_PULLUP
     GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
     GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;               //GPIO_MODE_OUTPUT_PP
     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);


     GPIO_InitStruct.Pin = GPIO_PIN_9;
     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);


     __I2C1_CLK_ENABLE();
     __I2C1_FORCE_RESET();
     __I2C1_RELEASE_RESET();


     hi2c1.Instance = I2C1;
     hi2c1.Init.ClockSpeed = 100000;
     hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
     hi2c1.Init.OwnAddress1 = 0xEE;
     hi2c1.Init.AddressingMode  = I2C_ADDRESSINGMODE_7BIT;
     hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
     hi2c1.Init.OwnAddress2     = 0;
     hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
     hi2c1.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLED;
     HAL_I2C_Init(&hi2c1);
}
void Single_WriteI2C(uint8_t REG_Address,uint8_t REG_data)
{
    uint8_t TxData[2] = {REG_Address,REG_data};
    HAL_StatusTypeDef i;
    uint8_t j=0;

    HAL_I2C_Master_Transmit(&hi2c1,0x94,(uint8_t*)TxData,2,4000);
}

int
main(int argc, char* argv[])
{
     I2C1_Init();
     Single_WriteI2C(0x02,0x01);

     while (1)
     {
    }
}

Hope someone could help me solve this issue, thanks all.

Outcomes