STM32 HAL I2C Driver - Wrong Slave Address
Hi, I have a board with STM32F501R8T6 and AT24C02 & DS1307 RTC are connected to I2C2. Earlier i had used custom I2C driver and interfaced them with a 8051 controller without any issues. Now since there is a need to change the I/0 pins config in ARM each time for read & write I had to chose the HAL library & use the Pins in I2C AF mode. I use STM32Cubemx for config.
To read the DS1307 registers i used
HAL_I2C_Mem_Read(&hi2c2,(uint16_t)0xD0<<1,0x0000,I2C_MEMADD_SIZE_8BIT,rxbuffer,3,1000); which returns HAL_OK and returns the value i had written using HAL MEM write command. However the clock never seemed to tick and i had changed RTC & crystal and still no luck. Finally today is when i found out that the data is being written and read from the EEPROM AT24C02 and not the RTC which is why the data is not advancing as it should in an RTC. The address for EEPROM is 0xA0. When I use 0xD0<<1 i noticed that inside HAL library the device address is 0x01A0. Is this a bug in HAL library? If i use 0xDO without left shift it returns HAL error. How can i access the RTC? Is there something wrong with my code or is there a bug in the HAL library??