cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L052K8U + DS3232M I2C not respond

Egor Vasilyev
Associate II

Hi, everybody. I have a problem, can not connect via I2C with RTC. Use a microcontroller and RTC STM32L052K8U DS3232M. Used library HAL. From the watch constantly comes NACK. The wizard sends the correct address (I'm sure of that, but just in case I also ran queries in a loop to addresses from 0x00 to 0xFF). Tightening on the I2C line is (there are resistors on 1K, voltage 3.3 V), on the power bus hours as 3.3 V, no batteries. Timing filed with MSI, and HSI, and PLLCLK (32 MHz). Below are screenshots of the settings. For what reason can the RTC not respond?

Datasheet on the clock:https://datasheets.maximintegrated.com/en/ds/DS3232M.pdf

int main(void){
  HAL_Init();
  SystemClock_Config();
 
  MX_GPIO_Init();
  MX_ADC_Init();
  MX_I2C1_Init();
  MX_USART1_UART_Init();
 
  while (1)  {
		uint8_t aTxBuffer[8];
		HAL_I2C_Master_Receive( &hi2c, (0x68 << 1), (uint8_t*) &aTxBuffer, (uint16_t)б uint32_t) 1000 ) != HAL_OK );
  }
}

0690X000006C12jQAC.png0690X000006C12oQAC.png0690X000006C12tQAC.png

5 REPLIES 5
AvaTar
Lead

Using a scope, have you looked at the I2C pins of the slave device ?

> From the watch constantly comes NACK.

This is not necessarily correct. No response at all is also interpreted as NACK.

Egor Vasilyev
Associate II

Да, �? проверил �?игнал на булавках �? о�?циллографом. У мен�? е�?ть 4 одинаковых у�?трой�?тва, и ни один из них не отвечает.

Egor Vasilyev
Associate II

Yes, I tested the signal on the clock pins with an oscilloscope. I have 4 identical devices and none of them are not responding.

You can't just jam reads like that. You need to select a register within the RTC to be reading.

See figure 10 in your data sheet

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Egor Vasilyev
Associate II

I also get the same reaction for the other addresses. According to the Datasheet, the value of seconds should be stored at 0x00. I managed to take a picture of the oscillogram.0690X000006C1DmQAK.jpg