You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm trying to use the I2C on a stm32l011 device but the code asserts during the unwrap of presc = u8(presc).unwrap() I believe (it's hard to debug due to the optimizations).
In any case looking at the code, I found the computations of the prescaler value strange : first a ratio is computed as i2cclk / freq - 4 which can be negative in case the apb1 clock is too small and later the prescaler value is computed as ratio / constant_value but I can't find any reference to the constant value (387 for fast-mode and 514 for standard-mode).
The original STM32 library builds on values computed by the STM32CubeMx tool and I can understand why this library does not want to rely on it but are you sure about the code calculating the i2c timing values ?
Looking at the reference manual I found there should be also the possibility of enabling the analog and digital filters. Overall I admit that setting up I2C on this device requires an intensive brain session 😭
The text was updated successfully, but these errors were encountered:
I started looking into how the I2C timings are computed tonight and based on AN4235 from ST and their old excel spreadsheet I wrote this python script to find correct values. The script final output for my configuration returns the same value than STM32CubeMx.
Forcing these values resulted in no assertions but now, i2c code is stuck, waiting for transmission completion.
Cool got it working, I had to change one of my pullups resistors.
The code in the python script is very brute force I don't know if moving it to the i2c initialization function is the right move. Ideally this could be done statically but the APB1 clock (and consequently the i2c kernel clock) is set during runtime.
Hello, I'm trying to use the I2C on a stm32l011 device but the code asserts during the unwrap of presc = u8(presc).unwrap() I believe (it's hard to debug due to the optimizations).
In any case looking at the code, I found the computations of the prescaler value strange : first a ratio is computed as
i2cclk / freq - 4
which can be negative in case the apb1 clock is too small and later the prescaler value is computed asratio / constant_value
but I can't find any reference to the constant value (387 for fast-mode and 514 for standard-mode).The original STM32 library builds on values computed by the STM32CubeMx tool and I can understand why this library does not want to rely on it but are you sure about the code calculating the i2c timing values ?
Looking at the reference manual I found there should be also the possibility of enabling the analog and digital filters. Overall I admit that setting up I2C on this device requires an intensive brain session 😭
The text was updated successfully, but these errors were encountered: