cancel
Showing results for 
Search instead for 
Did you mean: 

I2C STM32L053 problem

dree86
Associate II
Posted on April 29, 2016 at 12:19

Hello

I have question about i2c. My mcu i2c pin connect to i2c pin evaluation board BU945 My i2c init like this

I2C1Handle.Instance = I2C1;
I2C1Handle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
I2C1Handle.Init.Timing = I2C_TIMING_100KHZ;
I2C1Handle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
I2C1Handle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
I2C1Handle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
I2C1Handle.Init.OwnAddress1 = 0x00;
I2C1Handle.Init.OwnAddress2 = 0x00;
if(HAL_I2C_Init(&I2C1Handle) != HAL_OK)
{
/* Initialization Error */
//Error_Handler(); 
} 

I try to send HOME command 4 byte {0x61,0x03,0x01,0x01} slave address is 0x But when transmit it always return error HAL_I2C_ERROR_AF. Could someone help me please ? Thanks #i2c
1 REPLY 1
Walid FTITI_O
Senior II
Posted on April 29, 2016 at 19:38

Hi _.adri, 

you are missign to fill the I2C_address on the ''OwnAddress1''.

I recommend to check the I2C example in

http://www2.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubel0.html

at this path:

STM32Cube_FW_L0_V1.5.0\Projects\STM32L053C8-Discovery\Examples\I2C

-Hannibal-