2024-02-05 01:23 AM - last edited on 2024-02-05 07:36 AM by SofLit
Hello all,
I'm having problems with I2C1, i have a code that works perfectly while i configure the HCLK to 8MHz but it stops working when i set any higher frequency. Has anybody faced similar problem?
I am using STM32CubeIDE for setting the project, this microcontroller has a separate clock from HCLK, and i can't understand why I'm having this problem.
Thanks in advance.
2024-02-05 01:25 AM - edited 2024-02-05 01:26 AM
When you increase the HCLK, do you adjust the I2C to match?
And what, exactly, do you mean by "stops working"?
Have you viewed the I2C signals on a scope? How do they look?
2024-02-05 01:38 AM
Thank for your fast reply Andrew,
This is the way i configured the project trying to run the microcontroller at 16MHz (this node is working as slave), but with this configuration i can't receive anything on the master. But if i change de HCLK frequency to 8MHz, all works perfectly.
With "it's not working" i mean that with 8MHz in HCLK the comunication works as i expect but if i put any higher frequency te comunication stops.
I'm not seen the signals on the oscilloscope yet, i'm waiting for a mate to let me use his.
2024-02-05 02:00 AM
I am using STM32F042F6P6
2024-02-05 02:02 AM
Also show your configuration for 8MHz ...
2024-02-05 02:04 AM - edited 2024-02-05 02:05 AM
Here it is:
2024-02-05 02:05 AM
Here it is:
2024-02-05 05:56 AM
> it stops working
> te comunication stops
What exactly is happening that leads you to believe that communication stops? Does something in your code return an error message? Are the read values not as expected?
Are you debugging and stepping through the code or are you just running it and expecting an LED to blink or something, and inferring communcation stops from lack of the LED blinking?
2024-02-05 06:59 AM
Hello again Andrew,
How i have to adjust the I2C to match?
As far as i understand, setting de I2C frequency is enough for STM32CubeMX, and do not change that frequency when de system frequency changes (the STM32 automatically adjust de parameters i mean).
I think that because with the master i tried to change only de system frequency to diferent values and I2C still working on all of them.
Also i've been able to see the signals in the scope and when I2C works (with HCLK set to 8MHz) they look pretty well, but when i upgrade the frequency (as i explained), SCL drops to 0V and SDA is pulled up.
I attach two pictures of the comunnication working, in green SDA, in yellow SCL.
2024-02-05 07:03 AM
Yes, i'm sorry but i'm a beginner and i don't have a lot of knowledge debugging, with " not working" i mean that i'm not receiving the data on the master.
The code works in an specific frequency only, but in other projects i tried and no matters de frequency if the project is set with STM32CubeIDE or MX, the I2C still working.