-
Notifications
You must be signed in to change notification settings - Fork 3k
driver/i2c: STM32: I2C memory usage and time delay in read-write solved. #14776
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
driver/i2c: STM32: I2C memory usage and time delay in read-write solved. #14776
Conversation
Modified i2c_device.h file. This will solve I2C read write long time issue. Updated default I2C peripheral clock value to 160MHz. fix: ARMmbed#14732 Signed-off-by: Affrin Pinhero <[email protected]>
@affrinpinhero-2356, thank you for your changes. |
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.
targets/targets.json
Outdated
}, | ||
"i2c_timing_value_algo": { | ||
"help": "If value was set I2C timing algorithm is enabled. Enabling may leads to performance issue. Keeping this false and changing system clock will cause compilation error)", | ||
"value": true |
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.
Why this value is true ?
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.
No missed after testing. changed to false
1dd44d2
to
2c464c8
Compare
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 test is crashing with F072 Nucleo board :-(
okay. Let me run once again. Is there any specific error code that to check? |
I checked the issue:
|
|
2c464c8
to
1c10ea4
Compare
targets/TARGET_STM/i2c_api.c
Outdated
/* Only predefined timing for below frequencies are supported */ | ||
MBED_ASSERT((hz == 100000) || (hz == 400000) || (hz == 1000000)); | ||
/* Calculates I2C timing value with respect to I2C input clock and I2C bus frequency */ | ||
handle->Init.Timing = i2c_get_timing(obj_s->i2c, 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.
I hope this will solve.
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.
You forgot #ifdef I2C_IP_VERSION_V2
targets/TARGET_STM/i2c_api.c
Outdated
/* Only predefined timing for below frequencies are supported */ | ||
MBED_ASSERT((hz == 100000) || (hz == 400000) || (hz == 1000000)); | ||
/* Calculates I2C timing value with respect to I2C input clock and I2C bus frequency */ | ||
handle->Init.Timing = i2c_get_timing(obj_s->i2c, 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.
You forgot #ifdef I2C_IP_VERSION_V2
1c10ea4
to
ee3d0bd
Compare
break; | ||
true break; |
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 seems to be an error, the "true" here should not be there, I guess
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.
solved.
ee3d0bd
to
a06d6a6
Compare
Maybe i do something wrong when I compile it for NUCLEO_F091RC i get following error from debug console. I don't actually run it on nucleo but custom board in which case internal clock is used. I also did a test for custom board with external crystal setting - the result is the same In #define MBED_CONF_TARGET_I2C_TIMING_VALUE_ALGO 0 from debug
|
@jeromecoutant i'm at a06d6a6 |
@pilotak are you using default clock configuration or custom? |
@affrinpinhero-2356 default, as a said I compiled the code for NUCLEO_F091RC and ran on custom board |
@pilotak You need to change the value of |
@affrinpinhero-2356 could you please clarify what do you mean by default configuration? - does it mean that it will only work on nucleo with external clock and not with external crystal / internal clock? I didn't adjust anything so i'm using default setting |
/* If MBED_CONF_TARGET_I2C_TIMING_VALUE_ALGO assert is triggered. | ||
User needs to enable I2C_TIMING_VALUE_ALGO in target.json for specific target. | ||
Enabling this may impact performance*/ | ||
MBED_ASSERT(MBED_CONF_TARGET_I2C_TIMING_VALUE_ALGO); |
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.
Shouldn't this be an error rather and print a message how to fix it?
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.
Mentioned as a comment what to do assert occurred. So I think this will be enough.
}, | ||
"i2c_timing_value_algo": { | ||
"help": "If value was set I2C timing algorithm is enabled. Enabling may leads to performance issue. Keeping this false and changing system clock will cause compilation error)", | ||
"value": false |
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.
If this is false (default value), and I change system clock, why do I get compilation error?
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.
In this scenario, there will no error while compiling. But you may get an ASSERT while running.
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.
@affrinpinhero-2356 please update help description accordingly
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.
modified help 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.
ok thanks
Hi Maybe @pilotak issue is related to I2C_2 ? |
@jeromecoutant thanks for keep us updated! i've just had a quick look at this pr, but yes, by default the "i2c_timing_value_algo" should be enable for PORTENTA. |
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.
@jeromecoutant i'm using
|
Error when using
|
51ae319
to
2fae588
Compare
@affrinpinhero-2356 with 2fae588 it's working as expected. |
This pull request has automatically been marked as stale because it has had no recent activity. @jeromecoutant, @0xc0170, please complete review of the changes to move the PR forward. Thank you for your contributions. |
targets/targets.json
Outdated
}, | ||
"i2c_timing_value_algo": { | ||
"help": "If value was set to true I2C timing algorithm is enabled. Enabling may leads to performance issue. Keeping this false and changing system clock will trigger assert.)", | ||
"value": true |
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 don't think this is working ?
As PORTENTA_H7 is inheriting from MCU_STM32H7, "i2c_timing_value_algo" config already exist,
so I think you need to overwrite the value to true in the "overrides" part below ?
mbed test -m PORTENTA_H7_M7 -t ARM
[ERROR] Parameter name 'i2c_timing_value_algo' defined in both 'target:PORTENTA_H7' and 'target:MCU_STM32H7'
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.
Moved to overrides
@@ -3178,10 +3178,6 @@
"usb_speed": {
"help": "USE_USB_OTG_FS or USE_USB_OTG_HS or USE_USB_HS_IN_FS",
"value": "USE_USB_OTG_HS"
- },
- "i2c_timing_value_algo": {
- "help": "If value was set to true I2C timing algorithm is enabled. Enabling may leads to performance issue. Keeping this false and changing system clock will trigger assert.)",
- "value": true
}
},
"macros_add": [
@@ -3202,7 +3198,8 @@
"clock_source": "USE_PLL_HSE_EXTC",
"lse_available": 1,
"lpticker_delay_ticks": 0,
- "network-default-interface-type": "ETHERNET"
+ "network-default-interface-type": "ETHERNET",
+ "i2c_timing_value_algo": true
},
"device_name": "STM32H747XIHx"
},
This commit solves excess usage of RAM. User can now enable/disable I2C timing algorithm. Disabling of I2C timing algorithm would reduce RAM usage. Signed-off-by: Affrin Pinhero <[email protected]>
2fae588
to
8f24f09
Compare
CI started |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Summary of changes
This PR solves I2C Read Write Take long time and excess usage of RAM. Modified
i2c_device drivers to help user to enable disable I2C timing algorithm. Algorithm Disable
and enable can done using target.json.
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers