Skip to content

K22F/K64F: Add lp_ticker implementation and HAL lp_ticker tests #2476

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

Merged
merged 4 commits into from
Aug 25, 2016

Conversation

bulislaw
Copy link
Member

@0xc0170 Could you have a look please.

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 17, 2016

Please share the test results (compilers + those 2 targets) - paste them here

* limitations under the License.
*/

#if DEVICE_LOWPOWERTIMER
Copy link
Contributor

@bridadan bridadan Aug 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of #ifing-out the whole code here, could you instead add the following check:

#if !DEVICE_LOWPOWERTIMER
    #error [NOT_SUPPORTED] Low power timer not supported for this target
#endif

That will allow the tools to safely ignore this test for other targets that don't support the low power timer yet.

@bulislaw
Copy link
Member Author

GCC_ARM:

+--------------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+
| target       | platform_name | test suite               | test case                           | passed | failed | result | elapsed_time (sec) |
+--------------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 1ms LowPowerTimeout                 | 1      | 0      | OK     | 0.05               |
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout                | 1      | 0      | OK     | 1.04               |
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout from deepsleep | 1      | 0      | OK     | 1.06               |
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout from sleep     | 1      | 0      | OK     | 1.05               |
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 2sec LowPowerTimeout                | 1      | 0      | OK     | 2.04               |
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 3.5sec LowPowerTimeout              | 1      | 0      | OK     | 3.55               |
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 50us LowPowerTimeout                | 1      | 0      | OK     | 0.05               |
+--------------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+
+--------------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+
| target       | platform_name | test suite               | test case                           | passed | failed | result | elapsed_time (sec) |
+--------------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 1ms LowPowerTimeout                 | 1      | 0      | OK     | 0.04               |
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout                | 1      | 0      | OK     | 1.04               |
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout from deepsleep | 1      | 0      | OK     | 1.06               |
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout from sleep     | 1      | 0      | OK     | 1.06               |
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 2sec LowPowerTimeout                | 1      | 0      | OK     | 2.04               |
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 3.5sec LowPowerTimeout              | 1      | 0      | OK     | 3.55               |
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 50us LowPowerTimeout                | 1      | 0      | OK     | 0.05               |
+--------------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+

ARM:

+----------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+
| target   | platform_name | test suite               | test case                           | passed | failed | result | elapsed_time (sec) |
+----------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 1ms LowPowerTimeout                 | 1      | 0      | OK     | 0.05               |
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout                | 1      | 0      | OK     | 1.05               |
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout from deepsleep | 1      | 0      | OK     | 1.07               |
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout from sleep     | 1      | 0      | OK     | 1.06               |
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 2sec LowPowerTimeout                | 1      | 0      | OK     | 2.05               |
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 3.5sec LowPowerTimeout              | 1      | 0      | OK     | 3.55               |
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 50us LowPowerTimeout                | 1      | 0      | OK     | 0.05               |
+----------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+
+----------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+
| target   | platform_name | test suite               | test case                           | passed | failed | result | elapsed_time (sec) |
+----------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 1ms LowPowerTimeout                 | 1      | 0      | OK     | 0.05               |
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout                | 1      | 0      | OK     | 1.05               |
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout from deepsleep | 1      | 0      | OK     | 1.06               |
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 1sec LowPowerTimeout from sleep     | 1      | 0      | OK     | 1.06               |
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 2sec LowPowerTimeout                | 1      | 0      | OK     | 2.05               |
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 3.5sec LowPowerTimeout              | 1      | 0      | OK     | 3.55               |
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 50us LowPowerTimeout                | 1      | 0      | OK     | 0.05               |
+----------+---------------+--------------------------+-------------------------------------+--------+--------+--------+--------------------+

@bridadan
Copy link
Contributor

Thanks for making that change @bulislaw!

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 663

Build failed!

@bulislaw
Copy link
Member Author

Ah some failures on the Beetle, will have a look.

@bulislaw
Copy link
Member Author

/morph test

*/
#include "sleep_api.h"
#include "cmsis.h"
#include "system_core_beetle.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This include is not required it is already inside cmsis.h

@bulislaw bulislaw force-pushed the lp_ticker branch 2 times, most recently from a3c81ad to fd654d9 Compare August 18, 2016 10:29
@0xc0170
Copy link
Contributor

0xc0170 commented Aug 18, 2016

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 668

Test failed!

@bulislaw bulislaw force-pushed the lp_ticker branch 2 times, most recently from 298efc9 to 45d2bf3 Compare August 18, 2016 14:14
@bulislaw
Copy link
Member Author

Ok I set the timeouts to be less conservative as with big number of boards we can't really be that strict.

@bulislaw
Copy link
Member Author

Latest results:

+--------------+---------------+-------------------------------+-------------------------------------+--------+--------+--------+--------------------+
| target       | platform_name | test suite                    | test case                           | passed | failed | result | elapsed_time (sec) |
+--------------+---------------+-------------------------------+-------------------------------------+--------+--------+--------+--------------------+
| K22F-GCC_ARM | K22F          | tests-mbed_drivers-lp_timeout | 1ms LowPowerTimeout                 | 1      | 0      | OK     | 0.05               |
| K22F-GCC_ARM | K22F          | tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout                | 1      | 0      | OK     | 1.04               |
| K22F-GCC_ARM | K22F          | tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from deepsleep | 1      | 0      | OK     | 1.06               |
| K22F-GCC_ARM | K22F          | tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from sleep     | 1      | 0      | OK     | 1.06               |
| K22F-GCC_ARM | K22F          | tests-mbed_drivers-lp_timeout | 500us LowPowerTimeout               | 1      | 0      | OK     | 0.05               |
| K22F-GCC_ARM | K22F          | tests-mbed_drivers-lp_timeout | 5sec LowPowerTimeout                | 1      | 0      | OK     | 5.04               |
+--------------+---------------+-------------------------------+-------------------------------------+--------+--------+--------+--------------------+

+--------------+---------------+-------------------------------+-------------------------------------+--------+--------+--------+--------------------+
| target       | platform_name | test suite                    | test case                           | passed | failed | result | elapsed_time (sec) |
+--------------+---------------+-------------------------------+-------------------------------------+--------+--------+--------+--------------------+
| K64F-GCC_ARM | K64F          | tests-mbed_drivers-lp_timeout | 1ms LowPowerTimeout                 | 1      | 0      | OK     | 0.05               |
| K64F-GCC_ARM | K64F          | tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout                | 1      | 0      | OK     | 1.05               |
| K64F-GCC_ARM | K64F          | tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from deepsleep | 1      | 0      | OK     | 1.06               |
| K64F-GCC_ARM | K64F          | tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from sleep     | 1      | 0      | OK     | 1.06               |
| K64F-GCC_ARM | K64F          | tests-mbed_drivers-lp_timeout | 500us LowPowerTimeout               | 1      | 0      | OK     | 0.05               |
| K64F-GCC_ARM | K64F          | tests-mbed_drivers-lp_timeout | 5sec LowPowerTimeout                | 1      | 0      | OK     | 5.05               |
+--------------+---------------+-------------------------------+-------------------------------------+--------+--------+--------+--------------------+

+--------------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+
| target       | platform_name | test suite               | test case              | passed | failed | result | elapsed_time (sec) |
+--------------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 1ms lp_ticker          | 1      | 0      | OK     | 0.04               |
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 1s lp_ticker           | 1      | 0      | OK     | 1.04               |
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 1s lp_ticker deepsleep | 1      | 0      | OK     | 1.05               |
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 1s lp_ticker sleep     | 1      | 0      | OK     | 1.05               |
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 500us lp_ticker        | 1      | 0      | OK     | 0.05               |
| K64F-GCC_ARM | K64F          | tests-mbed_hal-lp_ticker | 5s lp_ticker           | 1      | 0      | OK     | 5.03               |
+--------------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+

+--------------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+
| target       | platform_name | test suite               | test case              | passed | failed | result | elapsed_time (sec) |
+--------------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 1ms lp_ticker          | 1      | 0      | OK     | 0.05               |
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 1s lp_ticker           | 1      | 0      | OK     | 1.04               |
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 1s lp_ticker deepsleep | 1      | 0      | OK     | 1.05               |
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 1s lp_ticker sleep     | 1      | 0      | OK     | 1.04               |
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 500us lp_ticker        | 1      | 0      | OK     | 0.04               |
| K22F-GCC_ARM | K22F          | tests-mbed_hal-lp_ticker | 5s lp_ticker           | 1      | 0      | OK     | 5.04               |
+--------------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+
+----------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+
| target   | platform_name | test suite               | test case              | passed | failed | result | elapsed_time (sec) |
+----------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 1ms lp_ticker          | 1      | 0      | OK     | 0.04               |
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 1s lp_ticker           | 1      | 0      | OK     | 1.04               |
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 1s lp_ticker deepsleep | 1      | 0      | OK     | 1.05               |
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 1s lp_ticker sleep     | 1      | 0      | OK     | 1.05               |
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 500us lp_ticker        | 1      | 0      | OK     | 0.05               |
| K64F-ARM | K64F          | tests-mbed_hal-lp_ticker | 5s lp_ticker           | 1      | 0      | OK     | 5.03               |
+----------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+
+----------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+
| target   | platform_name | test suite               | test case              | passed | failed | result | elapsed_time (sec) |
+----------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 1ms lp_ticker          | 1      | 0      | OK     | 0.04               |
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 1s lp_ticker           | 1      | 0      | OK     | 1.05               |
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 1s lp_ticker deepsleep | 1      | 0      | OK     | 1.06               |
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 1s lp_ticker sleep     | 1      | 0      | OK     | 1.05               |
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 500us lp_ticker        | 1      | 0      | OK     | 0.05               |
| K22F-ARM | K22F          | tests-mbed_hal-lp_ticker | 5s lp_ticker           | 1      | 0      | OK     | 5.04               |
+----------+---------------+--------------------------+------------------------+--------+--------+--------+--------------------+

Also the new tests are failing for Beetle board, it works allright for single waits, but there's a bug in lp_ticker implementation which makes consecutive waits hang (eg 2x1s wait, the second wait will never finish). I'll look into this now.

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 23, 2016

/morph test

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 23, 2016

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=GCC_ARM,ARM,IAR
TARGETS=K22F,K64F,KL27Z

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 23, 2016

LGTM

waiting for CI to finish

@bulislaw
Copy link
Member Author

The NUCLEO_F091RC is failing the new tests, I had a look and it seems that the lp_ticker implementation is broken. The IRQ handler is never called. I'm also sure there are more platforms like that, which will need to be looked at later.

@mbed-bot
Copy link

[Build 831]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 23, 2016

/morph test

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 23, 2016

From the mbed CI:

11:19:53 | K64F-IAR | K64F          | tests-mbed_drivers-lp_timeout    | 500us LowPowerTimeout                     | 0      | 1      | FAIL   | 0.31               |

Same for all toolchains

@mazimkhan Please check the jobs, tests FAIL (one failure, for instance check above code snippet I shared in this comment) and report UNSTABLE but here it's green?

@mazimkhan
Copy link

@0xc0170 CI fixed to show failure if there is any test failure.

@bulislaw
Copy link
Member Author

Tracked it down to ticker init happening to late for super short waits (just on first run after board was started), now it's being done in Ticker constructor. Which removes the extra delay from measurements.

@bridadan
Copy link
Contributor

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 687

All builds and test passed!

#define OSC32K_CLK_HZ (32768)
#define MAX_LPTMR_SLEEP ((1 << 16) - 1)

static int lp_ticker_inited = 0;
Copy link
Contributor

@0xc0170 0xc0170 Aug 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be more narrow type

API implemented using hybrid approach with RTC for longer periods and
LPTMR for subsecond ones.
Having it in the attach call introduces extra latency and can break
short delays, for the first usage.
@sg- sg- merged commit 3dac791 into ARMmbed:master Aug 25, 2016
@bulislaw bulislaw deleted the lp_ticker branch December 20, 2016 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants