cancel
Showing results for 
Search instead for 
Did you mean: 

I2C problem. I can't get the communication to work on STM32F0 Discovery in STM32CubeIDE. Where is the error in reasoning?

PReka.2
Associate II

Hello, I tried to run the RTC DS1307 first using libraries available on the internet. It was not successful. Later I tried to run the communication "manually" but it doesn't work either. Please help. 

The module with DS1307 works on Arduino. Through the Arduino I have set the output from the SQW Pin to flash every 1 Hz. Using STM I try to disable this function by typing

HAL_I2C_Mem_Write(&hi2c1, 0x68<<1, 0x07, 1, 0x00, 1, 1000);

but nothing happens. Please help me because I can't stand it anymore.

To sum up:

1 . I set configuration:

0693W00000NspqmQAB.jpg2 . Generate the code via Cube.

3 . Add one line of code:

 /* USER CODE BEGIN 2 */

 HAL_I2C_Mem_Write(&hi2c1, 0x68<<1, 0x07, 1, 0x00, 1, 1000);

 /* USER CODE END 2 */

and LED connected to SQW output of DS1307 is still blinking after uplode code to STM32F0 Discovery. What I do wrong?

Sincerely

Paweł

10 REPLIES 10

@PReka.2​  "Is it ok to use inernal pullups to I2C communications?"

As noted earlier, they will generally be too weak - but you might "get away" with it ...

A thread on I2C pullups:

https://electronics.stackexchange.com/questions/1849/is-there-a-correct-resistance-value-for-i2c-pull-up-resistors

In that thread, this picture shows the effects of the pullup value:

0693W00000Nt1crQAB.png 

Note that marking a solution doesn't close the thread - further replies can still be added.