Skip to content
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

Nuvoton: Adhere to reworked ticker spec to release with Mbed OS 5.9 #7029

Merged
merged 11 commits into from
Jul 2, 2018

Conversation

ccli8
Copy link
Contributor

@ccli8 ccli8 commented May 28, 2018

Description

This PR tries to adhere to reworked ticker spec to release with Mbed OS 5.9.

Targets

  • NUMAKER_PFM_NUC472
  • NUMAKER_PFM_M453
  • NUMAKER_PFM_M487
  • NUMAKER_PFM_NANO130

Pull request type

[ ] Fix
[X] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

@ccli8
Copy link
Contributor Author

ccli8 commented May 28, 2018

Greentea test (NUC472/ARM)

+------------------------+--------------------+----------------------------------------------------+--------+--------------------+-------------+
| target                 | platform_name      | test suite                                         | result | elapsed_time (sec) | copy_method |
+------------------------+--------------------+----------------------------------------------------+--------+--------------------+-------------+
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-lp_ticker               | OK     | 18.63              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-lp_timeout              | OK     | 56.3               | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-lp_timer                | OK     | 17.44              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-rtc                     | OK     | 27.3               | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-sleep_lock              | OK     | 12.95              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-ticker                  | OK     | 38.67              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-timeout                 | OK     | 54.97              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-timer                   | OK     | 20.03              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-timerevent              | OK     | 14.31              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | FAIL   | 30.55              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers_freq         | OK     | 34.1               | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-lp_ticker                   | OK     | 12.93              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-rtc_time                    | OK     | 14.24              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-rtc_time_conv               | OK     | 34.02              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-sleep_manager               | OK     | 12.04              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-sleep_manager_racecondition | OK     | 25.1               | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-ticker                      | OK     | 24.43              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-us_ticker                   | OK     | 13.03              | default     |
+------------------------+--------------------+----------------------------------------------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 FAIL / 17 OK

@ccli8
Copy link
Contributor Author

ccli8 commented May 28, 2018

Greentea test (M453/ARM)

+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
| target               | platform_name    | test suite                                         | result | elapsed_time (sec) | copy_method |
+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-lp_ticker               | OK     | 19.06              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-lp_timeout              | OK     | 57.99              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-lp_timer                | OK     | 18.45              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-rtc                     | OK     | 28.07              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-sleep_lock              | OK     | 13.01              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-ticker                  | OK     | 40.77              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-timeout                 | OK     | 54.29              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-timer                   | OK     | 20.76              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-timerevent              | OK     | 14.88              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-common_tickers              | FAIL   | 30.87              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-common_tickers_freq         | OK     | 34.46              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-lp_ticker                   | OK     | 13.28              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-rtc_time                    | OK     | 14.51              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-rtc_time_conv               | OK     | 34.63              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-sleep_manager               | OK     | 12.37              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-sleep_manager_racecondition | OK     | 25.82              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-ticker                      | OK     | 24.51              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-us_ticker                   | OK     | 12.85              | default     |
+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 FAIL / 17 OK

@ccli8
Copy link
Contributor Author

ccli8 commented May 28, 2018

Greentea test (M487/ARM)

+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
| target               | platform_name    | test suite                                         | result | elapsed_time (sec) | copy_method |
+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-lp_ticker               | OK     | 18.81              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-lp_timeout              | OK     | 58.08              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-lp_timer                | OK     | 18.13              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-rtc                     | OK     | 27.24              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-sleep_lock              | OK     | 12.23              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-ticker                  | OK     | 41.04              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-timeout                 | OK     | 54.71              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-timer                   | OK     | 20.48              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-timerevent              | OK     | 14.37              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-common_tickers              | FAIL   | 30.26              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-common_tickers_freq         | OK     | 35.32              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-lp_ticker                   | OK     | 13.26              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-rtc_time                    | OK     | 14.07              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-rtc_time_conv               | OK     | 35.71              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-sleep_manager               | OK     | 12.04              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-sleep_manager_racecondition | OK     | 25.76              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-ticker                      | OK     | 24.66              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-us_ticker                   | OK     | 12.45              | default     |
+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 FAIL / 17 OK

@ccli8
Copy link
Contributor Author

ccli8 commented May 28, 2018

Greentea test (NANO130/ARM)

+-------------------------+---------------------+----------------------------------------------------+--------+--------------------+-------------+
| target                  | platform_name       | test suite                                         | result | elapsed_time (sec) | copy_method |
+-------------------------+---------------------+----------------------------------------------------+--------+--------------------+-------------+
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-lp_ticker               | OK     | 18.92              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-lp_timeout              | OK     | 56.41              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-lp_timer                | OK     | 17.21              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-rtc                     | OK     | 28.0               | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-sleep_lock              | OK     | 13.21              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-ticker                  | OK     | 41.68              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-timeout                 | OK     | 52.78              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-timer                   | OK     | 20.09              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-timerevent              | OK     | 14.56              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-common_tickers              | FAIL   | 30.59              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-common_tickers_freq         | OK     | 35.46              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-lp_ticker                   | OK     | 12.96              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-rtc_time                    | OK     | 14.37              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-rtc_time_conv               | OK     | 33.49              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-sleep_manager               | OK     | 12.45              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-sleep_manager_racecondition | OK     | 24.99              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-ticker                      | OK     | 29.28              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-us_ticker                   | OK     | 12.87              | default     |
+-------------------------+---------------------+----------------------------------------------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 FAIL / 17 OK

@ccli8
Copy link
Contributor Author

ccli8 commented May 28, 2018

On all Nuvoton targets, mbed-os-tests-mbed_hal-common_tickers/lp ticker speed test is failed. This is H/W limitation. When Timer engine is clocked by low-power clock source LXT/LIRC, 3 engine clock delay is needed to make sure write access to it takes effect.

void lp_ticker_disable_interrupt(void)
{
    TIMER_DisableInt((TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname));
    wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
}
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | Microsecond ticker fire interrupt                               | 1      | 0      | OK     | 0.06               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | Microsecond ticker increment test                               | 1      | 0      | OK     | 0.09               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | Microsecond ticker info test                                    | 1      | 0      | OK     | 0.06               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | Microsecond ticker init is safe to call repeatedly              | 1      | 0      | OK     | 0.07               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | Microsecond ticker interrupt test                               | 1      | 0      | OK     | 0.06               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | Microsecond ticker overflow test                                | 1      | 0      | OK     | 12.88              |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | Microsecond ticker past interrupt test                          | 1      | 0      | OK     | 0.08               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | Microsecond ticker reschedule test                              | 1      | 0      | OK     | 0.06               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | Microsecond ticker speed test                                   | 1      | 0      | OK     | 0.06               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | lp ticker fire interrupt                                        | 1      | 0      | OK     | 0.05               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | lp ticker increment test                                        | 1      | 0      | OK     | 0.06               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | lp ticker info test                                             | 1      | 0      | OK     | 0.04               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | lp ticker init is safe to call repeatedly                       | 1      | 0      | OK     | 0.08               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | lp ticker interrupt test                                        | 1      | 0      | OK     | 0.09               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | lp ticker overflow test                                         | 1      | 0      | OK     | 0.07               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | lp ticker past interrupt test                                   | 1      | 0      | OK     | 0.07               |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | lp ticker reschedule test                                       | 1      | 0      | OK     | 0.1                |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | lp ticker speed test                                            | 0      | 1      | FAIL   | 0.17               |

@ccli8 ccli8 changed the title Nuvoton: Adhere to reworked ticker spec Nuvoton: Adhere to reworked ticker spec to release with Mbed OS 5.9 May 28, 2018
@0xc0170
Copy link
Contributor

0xc0170 commented May 28, 2018

Same as for RTC branch (my latest comment there) , this will be redirected to master once feature branch is integrated

@ccli8 ccli8 changed the base branch from feature-hal-spec-ticker to master May 29, 2018 02:52
@ccli8
Copy link
Contributor Author

ccli8 commented May 29, 2018

@0xc0170 I've done rebase onto master and change merge target branch to master.

@cmonr
Copy link
Contributor

cmonr commented May 29, 2018

@bulislaw Another HAL PR to check.

@cmonr cmonr requested a review from a team May 29, 2018 16:20
@bulislaw
Copy link
Member

@ccli8 can you use this mechanism to get that test to pass? #6536

@ccli8
Copy link
Contributor Author

ccli8 commented May 30, 2018

@bulislaw #6536 (LPTICKER_DELAY_TICKS) doesn't help. Nuvoton's situation gets worse. In Nuvoton's lp_ticker, all Timer register writes need delay. #6536 just fixes lp_ticker_set_interrupt with one delay. Nuvoton's lp_ticker_set_interrupt needs two delays (two Timer register writes). Besides, other APIs (lp_ticker_disable_interrupt, lp_ticker_clear_interrupt, etc.) also need at least one delay (one Timer register write).

@bulislaw
Copy link
Member

@c1728p9 how suitable would be to extend what we have to cover all cases?

@c1728p9
Copy link
Contributor

c1728p9 commented May 31, 2018

@bulislaw its hard to tell without knowing the exact use case. @ccli8 why does lp_ticker_disable_interrupt and lp_ticker_clear_interrupt require a delay? NVIC access should be immediate.

@ccli8
Copy link
Contributor Author

ccli8 commented Jun 1, 2018

why does lp_ticker_disable_interrupt and lp_ticker_clear_interrupt require a delay? NVIC access should be immediate.

These APIs have write access to Timer registers. Anyway, I will seek another means to make these APIs non-blocking.

Besides, I have questions about these ticker APIs:

  1. In lp_ticker_disable_interrupt, I shall disable Timer interrupt or NVIC interrupt (NVIC_DisableIRQ), or both?
  2. In lp_ticker_clear_interrupt, I shall clear Timer interrupt flag or also NVIC interrupt flag (NVIC_ClearPendingIRQ)?

@bulislaw @c1728p9

@c1728p9
Copy link
Contributor

c1728p9 commented Jun 1, 2018

In lp_ticker_disable_interrupt, I shall disable Timer interrupt or NVIC interrupt (NVIC_DisableIRQ), or both?

This is up to you @ccli8. Whichever is more straight forward for your to implement. The only requirement is that once lp_ticker_disable_interrupt is called you don't get interrupts. In this case it sounds like NVIC_DisableIRQ may be easier as it does not require a delay.

In lp_ticker_clear_interrupt, I shall clear Timer interrupt flag or also NVIC interrupt flag (NVIC_ClearPendingIRQ)?

The NVIC interrupt should get cleared automatically when you return from the given interrupt handler, so you should only need to clear the timer flag.

@ccli8
Copy link
Contributor Author

ccli8 commented Jun 4, 2018

@c1728p9 I fix the delay issue in 4668c8f.

@ccli8
Copy link
Contributor Author

ccli8 commented Jun 4, 2018

NUC472/ARM

+------------------------+--------------------+----------------------------------------------------+--------+--------------------+-------------+
| target                 | platform_name      | test suite                                         | result | elapsed_time (sec) | copy_method |
+------------------------+--------------------+----------------------------------------------------+--------+--------------------+-------------+
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-lp_ticker               | OK     | 18.75              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-lp_timeout              | OK     | 57.41              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-lp_timer                | OK     | 17.53              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-rtc                     | OK     | 27.3               | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-sleep_lock              | OK     | 12.04              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-ticker                  | OK     | 39.98              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-timeout                 | OK     | 55.3               | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-timer                   | OK     | 19.55              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_drivers-timerevent              | OK     | 13.93              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers              | OK     | 29.75              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-common_tickers_freq         | OK     | 34.35              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-lp_ticker                   | OK     | 12.78              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-rtc                         | OK     | 55.26              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-rtc_reset                   | OK     | 17.63              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-rtc_time                    | OK     | 13.91              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-rtc_time_conv               | OK     | 34.77              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-sleep_manager               | OK     | 11.91              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-sleep_manager_racecondition | OK     | 24.8               | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-ticker                      | OK     | 24.21              | default     |
| NUMAKER_PFM_NUC472-ARM | NUMAKER_PFM_NUC472 | mbed-os-tests-mbed_hal-us_ticker                   | OK     | 13.26              | default     |
+------------------------+--------------------+----------------------------------------------------+--------+--------------------+-------------+
mbedgt: test suite results: 20 OK

@ccli8
Copy link
Contributor Author

ccli8 commented Jun 4, 2018

M453/ARM

+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
| target               | platform_name    | test suite                                         | result | elapsed_time (sec) | copy_method |
+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-lp_ticker               | OK     | 19.13              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-lp_timeout              | OK     | 57.16              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-lp_timer                | OK     | 18.0               | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-rtc                     | OK     | 29.16              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-sleep_lock              | OK     | 12.75              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-ticker                  | OK     | 40.72              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-timeout                 | OK     | 54.34              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-timer                   | OK     | 20.39              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_drivers-timerevent              | OK     | 14.75              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-common_tickers              | OK     | 30.62              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-common_tickers_freq         | OK     | 36.11              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-lp_ticker                   | OK     | 13.31              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-rtc                         | OK     | 57.61              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-rtc_reset                   | OK     | 18.22              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-rtc_time                    | OK     | 14.76              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-rtc_time_conv               | OK     | 35.76              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-sleep_manager               | OK     | 12.78              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-sleep_manager_racecondition | OK     | 25.63              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-ticker                      | OK     | 24.88              | default     |
| NUMAKER_PFM_M453-ARM | NUMAKER_PFM_M453 | mbed-os-tests-mbed_hal-us_ticker                   | OK     | 13.54              | default     |
+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
mbedgt: test suite results: 20 OK

@ccli8
Copy link
Contributor Author

ccli8 commented Jun 4, 2018

M487/ARM

+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
| target               | platform_name    | test suite                                         | result | elapsed_time (sec) | copy_method |
+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-lp_ticker               | OK     | 18.75              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-lp_timeout              | OK     | 56.22              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-lp_timer                | OK     | 17.27              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-rtc                     | OK     | 27.33              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-sleep_lock              | OK     | 12.34              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-ticker                  | OK     | 39.9               | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-timeout                 | OK     | 54.91              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-timer                   | OK     | 19.66              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_drivers-timerevent              | OK     | 14.04              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-common_tickers              | OK     | 30.14              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-common_tickers_freq         | OK     | 35.4               | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-lp_ticker                   | OK     | 12.53              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-rtc                         | OK     | 55.55              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-rtc_reset                   | OK     | 17.42              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-rtc_time                    | OK     | 14.18              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-rtc_time_conv               | OK     | 34.91              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-sleep_manager               | OK     | 12.14              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-sleep_manager_racecondition | OK     | 25.04              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-ticker                      | OK     | 24.12              | default     |
| NUMAKER_PFM_M487-ARM | NUMAKER_PFM_M487 | mbed-os-tests-mbed_hal-us_ticker                   | OK     | 11.95              | default     |
+----------------------+------------------+----------------------------------------------------+--------+--------------------+-------------+
mbedgt: test suite results: 20 OK

@ccli8
Copy link
Contributor Author

ccli8 commented Jun 4, 2018

NANO130/ARM

+-------------------------+---------------------+----------------------------------------------------+--------+--------------------+-------------+
| target                  | platform_name       | test suite                                         | result | elapsed_time (sec) | copy_method |
+-------------------------+---------------------+----------------------------------------------------+--------+--------------------+-------------+
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-lp_ticker               | OK     | 18.33              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-lp_timeout              | OK     | 56.24              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-lp_timer                | OK     | 17.27              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-rtc                     | OK     | 27.53              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-sleep_lock              | OK     | 12.29              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-ticker                  | OK     | 41.09              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-timeout                 | OK     | 53.71              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-timer                   | OK     | 19.66              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_drivers-timerevent              | OK     | 13.99              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-common_tickers              | OK     | 30.11              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-common_tickers_freq         | OK     | 32.84              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-lp_ticker                   | OK     | 12.67              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-rtc                         | OK     | 55.38              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-rtc_reset                   | OK     | 17.29              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-rtc_time                    | OK     | 13.98              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-rtc_time_conv               | OK     | 34.35              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-sleep_manager               | OK     | 12.15              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-sleep_manager_racecondition | OK     | 24.98              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-ticker                      | OK     | 29.17              | default     |
| NUMAKER_PFM_NANO130-ARM | NUMAKER_PFM_NANO130 | mbed-os-tests-mbed_hal-us_ticker                   | OK     | 12.03              | default     |
+-------------------------+---------------------+----------------------------------------------------+--------+--------------------+-------------+
mbedgt: test suite results: 20 OK

1. Introduce S/W interrupt enable/disable to reduce calls to TIMER_EnableInt/TIMER_DisableInt.
2. Allow dummy interrupt because clear interrupt flag is not synchronized.
3. Enable LPTICKER_DELAY_TICKS to make lp_ticker_set_interrupt non-blocking.
This is to make us_ticker/lp_ticker code consistent.
This is to make us_ticker/lp_ticker code consistent.
@ccli8
Copy link
Contributor Author

ccli8 commented Jun 26, 2018

Do rebase on master to fix conflict

@c1728p9
Copy link
Contributor

c1728p9 commented Jun 27, 2018

Hi @ccli8 I took an in-depth look into this on the NUMAKER_PFM_M453. I was unable to reproduce the problems you describe with requiring a delay to clear the interrupt. I used GPIO to record the timing of tmr1_vec, lp_ticker_clear_interrupt and lp_ticker_set_interrupt. I found that even if I removed NVIC_DisableIRQ from tmr1_vec the interrupt would not fire repeatedly. Further, writes to timer_base->CMP and timer_base->INTSTS seemed to effect immediately. Even if I waited in a loop for the operation to take effect (reading CMP or INTSTS until it matched expected) neither took more than 5us. This is much shorter than the ~30us of a single low power clock cycle.

A screenshots of the timing can be seen below. None of the functions take more than 10us to execute. Test code used for this screenshot and for the testing above can be found on the lp_timer_test_code branch of my mbed-os repo.

image

Further I looked through the Reference Manual but didn't see any information about synchronization delays when using the TMR module. Could this already be handled by hardware?

Summary - @ccli8 would it be possible to remove the special handling needed for lp_ticker_disable_interrupt? If not could you point me to documentation or example code showing why or demonstrating the failures you are seeing?

It is because dummy interrupt is very rare or pending time caused by it
is very short.
This is to make us_ticker/lp_ticker code consistent.
@ccli8
Copy link
Contributor Author

ccli8 commented Jun 28, 2018

@c1728p9 Many thanks for your in-depth look. Re-checking with our designer, I have to fix my point. For LXT/LIRC-clocked Timer (lp_ticker), there are synchronization issues with register control. Before that, I have to clarify two clock domains:

  • PCLK: typical HCLK/2
  • ECLK (engine clock): LXT/LIRC (30us/100us) for Timer used to implement lp_ticker
  1. For write CMP to take effect, it takes typical 1PCLK + 2ECLK. Read-check is not enough because it just checks PCLK domain and doesn't check into ECLK domain.
  2. For clear interrupt flag to take effect, it takes typical 2PCLK. It is very rare that we would meet dummy interrupt and get stuck in ISR until 'clear interrupt flag' takes effect. The issue is ignorable because the pending time is very short (at most 1 dummy interrupt). This also explains why you didn't meet dummy interrupt (and I also didn't). Needing no special handling for it, I remove lp_ticker_disable_interrupt in ISR.

TIMER_ClearIntFlag((TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname));
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
/* To avoid sync issue, we clear TIF/TWKF simultaneously rather than call separate
* driver API:
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is on the PCLK domain does writing these separately cause issues? If not you could revert this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@c1728p9 TIMER_ClearIntFlag/TIMER_ClearWakeupFlag are so close. It is safer to clear these interrupt flags altogether.


/* Disable wakeup */
TIMER_DisableWakeup(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this wait_us needed? Same question for the wait_us below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@c1728p9 All these wait_us are necessary.

* It is very rare that we would meet dummy interrupt and get stuck in ISR until
* 'clear interrupt flag' takes effect. The issue is ignorable because the pending
* time is very short (at most 1 dummy interrupt). We won't take special handling for it.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this comment 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@c1728p9 Re-thanks for your detailed review.

@cmonr
Copy link
Contributor

cmonr commented Jun 30, 2018

/morph build

@@ -52,6 +52,7 @@ unsigned int ticker_overflow_delta;

/* Auxiliary function to count ticker ticks elapsed during execution of N cycles of empty while loop.
* Parameter <step> is used to disable compiler optimisation. */
MBED_NOINLINE
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this inserted?

Copy link
Contributor

Choose a reason for hiding this comment

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

Never mind. Commit b18f690 explained it perfectly.

@cmonr
Copy link
Contributor

cmonr commented Jun 30, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jun 30, 2018

Build : SUCCESS

Build number : 2485
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7029/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

1 similar comment
@mbed-ci
Copy link

mbed-ci commented Jun 30, 2018

Build : SUCCESS

Build number : 2485
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7029/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Jun 30, 2018

@mbed-ci
Copy link

mbed-ci commented Jun 30, 2018

@0xc0170 0xc0170 merged commit 2353e7b into ARMmbed:master Jul 2, 2018
@cyliangtw cyliangtw deleted the nuvoton_5.9_ticker branch March 9, 2023 05:25
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.

None yet

6 participants