-
Notifications
You must be signed in to change notification settings - Fork 39
[Observation] Disabling an IOM causes much badness on v2.1 #412
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
Comments
The problem is with Wire.end(). Actually there are 2 issues and a catch-22: Current situation Next time around when you call Wire.Begin(), it believes the MBED-OS I2C instance is still valid and NO init is performed. As the module is powered-down in the sketch, it will stay powered down and will cause a crash during write / am_hal_iom_blocking_transfer. When you enable the power to the module again in the sketch before calling Wire.begin(), the configuration settings in IOM are still not re-initialized with Wire.begin() and will stay on it’s default values. Hence no output. P.s. Although the allocated memory for the instance was released, the content is still there. Hence it can still be used, BUT that is only until the memory is re-used for other purposes. Second situation
There is a call i2c_free() in i2c_api.c (part of Apollo3 target) which can release and powerdown the IOM, but MBED-OS I2C.cpp does not have any call that can be used to reference that. Now what?
Wire.end() Wire.begin()
to
When setting the frequency it will do a de-init and init which will reset the configuration settings in the IOM. Now when in the sketch power is disabled with am_hal_pwrctrl_periph_disable() manually, one should restore the power with am_hal_pwrctrl_periph_enable() manually as well before calling Wire.begin(). Given the change with setClock() it will reset the configuration parameters for the IOM. If you do not enable the power back before calling begin, the am_hal_iom_disable() will fail as part of de-init (for frequency change) as it tries to write to the IOM that does not have power. Paul |
Thank you Paul - much appreciated! |
OpenLog Artemis puts the Aretmis into deep sleep between measurements to save battery power.
With v1.2 of the core, we could disable the I2C IOM to save a little extra power.
With v2.1 of the core, this causes much badness...
Steps to reproduce:
Apollo3 core v1.2.1
RedBoard Artemis ATP
Connect an oscilloscope to the standard SCL and SDA pins (39 and 40)
Run the following example:
The serial monitor should show:
The 'scope should show:
Switch to v2.1 of the core and we get:
It looks like the second Wire.begin is not re-enabling the IOM for us.
If we enable it manually by changing the code to:
The HardFault goes away:
But we only see the first transaction on the Wire bus. The second transaction is MIA...
Cheers,
Paul
The text was updated successfully, but these errors were encountered: