AnsweredAssumed Answered

STM32L1 I2C register read problem

Question asked by Lorant Bugar on Apr 24, 2018
Latest reply on Apr 24, 2018 by john doe


I have for me big problem with I2C. I would like communicate with DS3231 RTC chip.

I wroted small easy code :


void DS3231_DateTime_get(void)
DS3231.ds3231_TX_buff[0] = 0x00;

HAL_I2C_Master_Transmit(&hi2c1, DS3231_address << 1, &DS3231.ds3231_TX_buff[0], 1, 1000);
HAL_I2C_Master_Receive(&hi2c1, DS3231_address << 1, &DS3231.ds3231_RX_buff[0], 7, 1000);

//HAL_I2C_Mem_Read(&hi2c1, DS3231_address << 1, 0x00, I2C_MEMADD_SIZE_8BIT, DS3231.ds3231_RX_buff, 7, 1000);

DS3231.second = BCD2DEC(DS3231.ds3231_RX_buff[0]);
DS3231.minute = BCD2DEC(DS3231.ds3231_RX_buff[1]);
DS3231.hour = BCD2DEC(DS3231.ds3231_RX_buff[2]); = BCD2DEC(DS3231.ds3231_RX_buff[3]); = BCD2DEC(DS3231.ds3231_RX_buff[4]);
DS3231.month = BCD2DEC(DS3231.ds3231_RX_buff[5]);
DS3231.year = BCD2DEC(DS3231.ds3231_TX_buff[6]);



In first cycle I read data good (data is visualized with VIsual GDB in Visual studio in debugging mode, but I tried with stmstudio or send over uart equal is same  ) - data is hexadecimal


after first cycle in following cycles I read every register 0x00...


after restart procvesor first cycle to same good every following 0x00.

I use CubeMX 4.25


FW 1.8.1

I tried event interrupt enable. 

please help.


thank you