2023-09-15 01:06 PM - edited 2023-09-15 01:07 PM
Every time I need to configure I2C, which is not often, I have to check the correct rise and fall times for the default 100kHz frequency and doing so I am asking myself a question why the typical 100kHz value is provided by default but rise and fall times are not, when most of the time 1000 and 300ns values are needed and I2C will NOT work with default values 0. Would not it increase user experience if the correct, typical values were provided in addition to the typical clock frequency?
Btw, CubeMX calculated timings are slightly off the I2C specs and conditions defined in ST RM docs. I believe the CubeMX algorithm is incorrect. Therefore I suggest to always enable the 'advanced settings' and allow the user to enter timings manually. Explaining why the calculation algorithm is incorrect is beyond the scope of this post.
2023-09-16 01:56 AM
btw did you ever check the real rise/fall times ?
+ from rm:
2023-09-16 01:55 PM - edited 2023-09-16 02:15 PM
@AScha.3 I usually check the actual rise/fall time, but why does it matter? You seem to be missing my point.
In a standard 100kHz mode max rise time for both SDA and SCL signals is 1000ns and max fall time is 300ns. Consequently, default CubeMX settings should accommodate for the maximum allowable rise/fall times. Of course, when the actual measurements are obtained fine tunning could be made, but why not to set those rise/fall times (and consequently SCLDEL/SDADEL) to safe values by default? If the actual times are shorter then max allowed, nothing bad would happen.
Current default rise/fall time values 0 (zero) are always incorrect.
Please e.g. refer to RM0456, Table 655. This table mentions SMBus, but timings apply to non-SMBus as well. See NXP document UM10204, table 10, p.48. and other I2C standard specs.
For the detailed discussion refer to RM0456 p. 2683-2685.
2023-09-16 02:03 PM
> Current default rise/fall time values 0 (zero) are always incorrect.
@TDJ Are you considering that this behavior of Cube works "well enough" for a lot of users, for long time?
2023-09-16 02:19 PM
@Pavel A. And how do you actually know that?
2023-09-16 02:28 PM - edited 2023-09-16 03:17 PM
@Pavel A. Recently I discovered that setting I2C digital filter in CubeMX had no meaning, it did not generate the required HAL function call. The problem was not limited just to a particular MCU. Nobody noticed this for years and it is fixed now. Does it suggest that previously I worked well enough? I guess, it depends on how you define "well enough" or rather whether or not CubeMX team strives for excellence or just barely "good enough".
2023-09-17 03:13 PM
@TDJ I know more than several companies and individuals who use CubeMX/IDE for several years already; none of them has major issues with I2C configuration. Questions arise from time to time, and get answered.
2023-09-17 03:20 PM
Yes the digital filter is a known issue. Can't tell much on this except that every time I've asked my board designers what to do with the digital filter, they told to ignore it. And the products worked fine AFAIK. But we never had to reduce the bitrate below 100 KHz. For several years on this forum I can't recall such requirement. Of course bugs should be fixed.... in order of priority.
2023-09-18 02:45 AM - edited 2023-09-18 02:55 AM
@Pavel A. Essentially, I suggest CubeMX improvement, improvement helping less experienced engineers to get I2C working right "out of the box" because the default zero rise/fall times prevent that.
To that you replay that you know several companies using CubeMX which are happy.
Fine, I just do not see how this is relevant.
I could tell you about companies (large ones) which, for a good reason, would not even consider using CubeMX to generate any production I2C code, but, again, this is not relevant here.
2023-09-18 03:54 AM - edited 2023-09-18 03:56 AM
What I tried to tell, I2C code generated by Cube without modification (zero rise/fall times) actually works "well enough" for many users counting myself. So I'm curious why it fails for you, is it related to the clock timing alone or properties of the wires (termination, noise isolation etc.)?
Bug reports against Cube can be raised in this forum, but it's better if you have a FAE contact or open a support request here.