2016-11-21 10:32 AM
hi all
i run a tiny project with STM32L433 and have a problem with i2c protocol , i have a MCP79410 microchip real time chip and use it for this project after i initialize i2c with HAL DRIVER i should use HAL APIs like HAL_I2C_MASTER_TRANSMIT(); ok , that so easy , but one problem occur : it function just write on the bus . its mean when i send address device than chip can write on the bus : for example i need to access contents in 0x02 register location on device target , after i use this function and write 0x02 on bus, i cant read any byte on bus because this function only write on the bus and when end , it close the bus , i need to content after called register address :( it same not possible #hal_dr #stm32l4 #i2c #stm32l4332016-11-22 04:50 AM
hello az.ahahab
try to use the method HAL_I2C_Master_Receive() instead.2016-11-22 06:55 AM
thanks arnold for replay
ok . np . problem is here . both this function only can read or write . i should send address register first and than read content on this address! it mean function we called HAL_I2C_Master_Receive() just can read from bus and cant write address we need than read the bus . and problem is in parameter it can pull, attention this : HAL_I2C_Master_Receive(&hi2c1,0xdf,I2C_DATA,3,5) one : pointer of i2c we used two: address device three:pointer to save read data on bus for:number of data on bus five:timeout ok , so i havent any parameter for called what register i need to save it content than save it content on my buffer(i2c_data) problem is here2016-11-22 07:09 AM
Hello,
I recommend you to have a look to the working examples under the STM32CubeL4 package, it may be helpful: STM32Cube_FW_L4_V1.5.0\Projects\STM32L476G_EVAL\Examples\I2CYou can inspire from the provided application, check your needed functions with regarding passed parameters.Regards2016-11-22 07:28 AM
2016-12-12 07:37 AM
I have this problem yet, please help me . i need make a connection with RTC chips , i need to make start bit and go into receive mode before stop bit event , in HAL FUNCTION its function is lost and no more create for this problem .
>:(
2016-12-22 03:31 AM
i solved this problem but with cross-cut way:
i used this function but i cant guaranty that for work with all chips,otherwise this function work with chips that support random read sequence and it work greatly:
HAL_I2C_Mem_Read();
thanks all