-
Notifications
You must be signed in to change notification settings - Fork 3k
STM32H7: Compute I2C timing according current I2C clock source #14030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@facchinm, thank you for your changes. |
@jeromecoutant nope, it's from https://github.com/STMicroelectronics/STM32CubeH7/blob/beced99ac090fece04d1e0eb6648b8075e156c6c/Drivers/BSP/STM32H747I-DISCO/stm32h747i_discovery_bus.c (as reported in the description). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I2C tests are failed with this patch with NUCLEO_H743ZI2
@jeromecoutant you mean in your internal hardware CI? |
Yes, with this test: |
A particular test case or just all of them? |
Note I added quick printf to display new values: |
6a0ed52
to
86ee300
Compare
This PR cannot be merged due to conflicts. Please rebase to resolve them. |
Hi @jeromecoutant i've updated the patch adding
I2c_valid_timing_nbr must be cleared each time a new calculation is performed to make sure only valid values of I2c_valid_timig array are considered. Now it shouldn't raise any exception. Could you please re-run tests? If everything runs fine i will then rebase.
|
Hi @pennam ci-test-shield I2C test is now OK! But unfortunately, FPGA I2C test was OK, and is now FAILED... |
@jeromecoutant thanks for the reports, at least is not crashing anymore. Next week, most probably on wednesday, i will have an fpga shield to make further investigations on this issue. |
@jeromecoutant i've received the fpga shield and made several tests, from my side I2C tests are always ok. I'm using STM32H747I-DISCO board. Could you please check if test are always failing on your board or it was just a glitch? |
This pull request has automatically been marked as stale because it has had no recent activity. @facchinm, please carry out any necessary work to get the changes merged. Thank you for your contributions. |
I confirm that with H747 DISCO is OK... |
I2c_valid_timing_nbr = 0; | ||
|
||
/* we will use D2PCLK1 to calculate I2C timings */ | ||
MBED_ASSERT(RCC_I2C1CLKSOURCE_D2PCLK1 ==__HAL_RCC_GET_I2C1_SOURCE()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is strange as H747-DISCO is suing I2C4 for D14/D15 pins.
NUCLEO H743 is using I2C1...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When i wrote this line i was making wrong assumptions and it is completely useless. On DISCO I2C1_SOURCE is actually D2PCLK1 so we never hit the assert, moreover as you wrote I2C4 is used for the tests... On DISCO tests are ok because PCLK1_Frequency, PCLK2_Frequency, PCLK3_Frequency and PCLK4_Frequency have all the same value.
On the other side I2C1 instance is used for running tests on the NUCLEO and we doesn't hit the assert too, this means we are using the correct clock source to compute timings... so i thinks there is something else i'm missing to make things work on the NUCLEO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes seems not compliant with all I2C instances
LL_RCC_ClocksTypeDef rcc_clocks; | ||
LL_RCC_GetSystemClocksFreq(&rcc_clocks); | ||
|
||
tim = I2C_ComputeTiming(rcc_clocks.PCLK1_Frequency, hz); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I2C4 seems connected to PCLK2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from my understanding I2C4 on DISCO uses RCC_I2C4CLKSOURCE_D3PCLK1 as clock source that is the same of rcc_clocks.PCLK4_Frequency. I don't know why here https://github.com/STMicroelectronics/STM32CubeH7/blob/beced99ac090fece04d1e0eb6648b8075e156c6c/Drivers/BSP/STM32H747I-DISCO/stm32h747i_discovery_bus.c#L224 PCLK2 is used. From the reference manual I2C4 can be used with PCLK4, PLL3, HSI and CSI.
I need to understand how to get the correct clock source of each I2C instance. I start working on it now. |
I've found a way to use the proper clock source for any I2C instance, hopefully tomorrow i will get a NUCLEO board to repeat test on my side. |
Jenkins CI Test : ❌ FAILEDBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
targets/TARGET_STM/i2c_api.c
Outdated
#ifdef TARGET_STM32H7 | ||
handle->Init.Timing = get_i2c_timing(obj_s->i2c, hz); | ||
#else | ||
handle->Init.Timing = get_i2c_timing(hz); | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be kept within #ifdef I2C_IP_VERSION_V2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed it and added i2c_device.c to CMakeLists.txt
CI started |
Jenkins CI Test : ❌ FAILEDBuild Number: 2 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About last correction in stm32h7xx_hal_rcc_ex.h
correction is approved by ST driver team and will be present in the next delivery.
Thx a lot
@0xc0170 ping :-) |
CI started |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 3 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Summary of changes
I2C clock dividers were calculated based on the assumption that the feed clock is always 54MHz.


Borrow the proper calculation from STM32CubeH7
Impact of changes
Migration actions required
Documentation
None
Pull request type
Test results
Reviewers
@jeromecoutant @pennam