2022-12-02 02:21 AM
HI Team,
We are using the STM32WB controller for our project, in that we are using the I2C1 for to communicate with Eeprom Module.
Can anyone explain how to configure/Calculate the Exact Timing Register value. If we have any sample calculator for different I2C Speeds along with other register settings it is very helpful to us.
Currently My Register value: hi2c1.hi2c1.Init. Timing = 0x00000E14, for which I2C speed it is calculated we are not understanding.
Regards,
Srinivas.V
2022-12-02 01:11 PM
Why would you just not use CubeMX to give you the setup code? You just type in the I2C speed that you want and it gives you the timing value.
Is learning the minutiae of poking timing registers the important bit (is this to pass some course) or is getting your device running the important thing?
Either way, read the I1C section of the reference manual.
2022-12-02 01:30 PM
Well it does cause a lot of people not knowing how anything actually works.
Perhaps one could take the Reference Manual, and unpack the register, and see how it divides the APB clock, and modulates the waveform.
If you're dealing with a lot of I2C peripherals, assorted STM32, and perhaps want to do some adaptive clock-gearing, being able to change it on the fly becomes more important.
This gets to be more important if people just randomly cut-n-paste things between projects or families of parts, as they are context sensitive, and often dependent on them even being commented correctly.
ST should really provide algorithms to pack and unpack these "constants" so the process is less opaque.
2022-12-04 01:03 PM
Proper calculation of the I2C timings is not just a single formula, but is an algorithm. If the HAL developers would be competent, they would implement this algorithm in the HAL initialization/configuration functions. After all HAL is meant to be a high level Hardware Abstraction Layer!
2022-12-05 09:43 AM
Hi Piranha,
Thanks for your reply.
Can you just explain how the value is calculated in example project, "hi2c1.hi2c1.Init. Timing = 0x00000E14". we are trying to recalculate the same but not able to understand and same value is not getting with any of the settings which are in STMCubeMx Tool.
Could you please explain and corelate the example project value with STMCubeMx Tool, how it is generated, based on that we will generate the values for our project with Different I2C speeds.
We have downloaded the one excel exe which is for Timing Regester value generation, with that one also we are not able to corelate the Example project Register value.
Example project Path:
ST\STM32CubeWB-master\Projects\P-NUCLEO-WB55.Nucleo\Examples\I2C\I2C_TwoBoards_ComDMA
Excel sheet Name:
I2C_Timing_Configuration_V1.0.1
Regards,
Srinivas
2022-12-08 02:50 AM
Hello @User16669512935851271792,
I suggest you look to the Reference manual (RM0478) in Sections for more details:
You find formulas to understand as a reference.
Foued
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-12-08 06:14 AM
Hi Khalsi,
Thanks for your reply.
I already overlooked into this document and crosschecked the registers, but still i am unable to simulate the TIMING REGISTER Value.
We have referred the Example code and they are using the value hi2c1.hi2c1.Init. Timing = 0x00000E14, we also reusing the same example code and only change is we need to run in Higher speeds like 400Khz and 1 Mz. For this we need to update the Timing Reg value, and rest of the settings are same. For that only we are asking how this value is generated and what are the values they have used for Rise and Fall Time values. If we know these values, we will generate the reg Value for different speeds.
Just explain the Example project Timing Reg value, that is sufficient for us.
Regards,
Srinivas.V
2022-12-08 06:55 AM
Hello,
For the Timing register value : 0x00000E14, the Rise Time = 0 ns and the Fall time = 0 ns too,
For example : for Fast mode (400KHz) :
this timing register value is generated automatically by the STM32CubeMX.
Foued
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-12-08 07:02 AM
Thanks for your reply.
In your image The Timing Reg value is showing 0x00004, But the value is example project is 0x00000E14.
Please mention the I2C Clock source Frequency, Analog Filter Delay, Coefficient of Digital Filter and Rise and Fall times.
we are using the excel sheet for generating the Timing Register value. Attached the same in reply.
Regards,
Srinivas.V
2022-12-08 07:31 AM
The timing register value is 0x00000004 generated automatically by the STM32CubeMX for :
Foued
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.