Nuvoton
/
NuMaker-mbed-tickless-example
NuMaker tickless example
README.md@8:acff1b7adc39, 2017-10-18 (annotated)
- Committer:
- ccli8
- Date:
- Wed Oct 18 14:24:42 2017 +0800
- Revision:
- 8:acff1b7adc39
- Parent:
- 1:eb1da9d36e12
- Child:
- 14:83b73695da8f
Update README.md
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ccli8 |
1:eb1da9d36e12 | 1 | # Example for tickless support on Nuvoton targets |
ccli8 |
1:eb1da9d36e12 | 2 | |
ccli8 |
1:eb1da9d36e12 | 3 | This is an example to demonstrate [tickless](https://en.wikipedia.org/wiki/Tickless_kernel) support on |
ccli8 |
1:eb1da9d36e12 | 4 | Nuvoton Mbed-enabled boards. |
ccli8 |
1:eb1da9d36e12 | 5 | With tickless support, user program would enter **Idle** mode (shallow sleep) or **Power-down** mode (deep sleep) |
ccli8 |
1:eb1da9d36e12 | 6 | automatically when CPU is idle. |
ccli8 |
1:eb1da9d36e12 | 7 | |
ccli8 |
1:eb1da9d36e12 | 8 | ## Supported platforms |
ccli8 |
1:eb1da9d36e12 | 9 | - [NuMaker-PFM-NUC472](https://developer.mbed.org/platforms/Nuvoton-NUC472/) |
ccli8 |
1:eb1da9d36e12 | 10 | - [NuMaker-PFM-M453](https://developer.mbed.org/platforms/Nuvoton-M453/) |
ccli8 |
1:eb1da9d36e12 | 11 | - [NuMaker-PFM-M487](https://developer.mbed.org/platforms/NUMAKER-PFM-M487/) |
ccli8 |
1:eb1da9d36e12 | 12 | |
ccli8 |
1:eb1da9d36e12 | 13 | ## Supported wake-up source |
ccli8 |
1:eb1da9d36e12 | 14 | - Button(s) |
ccli8 |
1:eb1da9d36e12 | 15 | - lp_ticker (internal with tickless) |
ccli8 |
1:eb1da9d36e12 | 16 | - WDT timeout |
ccli8 |
1:eb1da9d36e12 | 17 | - RTC alarm |
ccli8 |
1:eb1da9d36e12 | 18 | - UART CTS state change (TODO) |
ccli8 |
1:eb1da9d36e12 | 19 | - I2C address match (TODO) |
ccli8 |
1:eb1da9d36e12 | 20 | |
ccli8 |
1:eb1da9d36e12 | 21 | ## Execution |
ccli8 |
1:eb1da9d36e12 | 22 | To run this tickless example, target board must run with no ICE connected. |
ccli8 |
1:eb1da9d36e12 | 23 | With ICE connected, system will enter **Idle** mode (shallow sleep) rather than **Power-down** mode (deep sleep) |
ccli8 |
1:eb1da9d36e12 | 24 | even though `deepsleep()` is called. |
ccli8 |
1:eb1da9d36e12 | 25 | |
ccli8 |
1:eb1da9d36e12 | 26 | ### Modes |
ccli8 |
1:eb1da9d36e12 | 27 | There are two modes on Nuvoton Mbed-enabled boards: |
ccli8 |
1:eb1da9d36e12 | 28 | |
ccli8 |
1:eb1da9d36e12 | 29 | #### MASS mode |
ccli8 |
1:eb1da9d36e12 | 30 | This mode supports drap-n-drop programming and VCOM. For retrieving chip information, ICE is connected and system cannot enter |
ccli8 |
1:eb1da9d36e12 | 31 | **Power-down** mode. |
ccli8 |
1:eb1da9d36e12 | 32 | |
ccli8 |
1:eb1da9d36e12 | 33 | #### Debug mode |
ccli8 |
1:eb1da9d36e12 | 34 | This mode supports debugger and VCOM. But without entering debug session for debugging, ICE isn't connected and system can enter |
ccli8 |
1:eb1da9d36e12 | 35 | **Power-down** mode (deep sleep). |
ccli8 |
1:eb1da9d36e12 | 36 | |
ccli8 |
1:eb1da9d36e12 | 37 | So to run this tickless example, user must switch to **MASS** mode first for drag-n-drop programming and |
ccli8 |
1:eb1da9d36e12 | 38 | then switch to **Debug** mode without entering debug session for running the code. |
ccli8 |
1:eb1da9d36e12 | 39 | |
ccli8 |
1:eb1da9d36e12 | 40 | ### Note for terminal output |
ccli8 |
1:eb1da9d36e12 | 41 | With your terminal program configured with 9600/8-N-1, you would see output with: |
ccli8 |
1:eb1da9d36e12 | 42 | <pre> |
ccli8 |
1:eb1da9d36e12 | 43 | I am going to shallow/deep sleep |
ccli8 |
1:eb1da9d36e12 | 44 | Wake up by WDT timeout from <b>deep sleep</b> |
ccli8 |
1:eb1da9d36e12 | 45 | |
ccli8 |
1:eb1da9d36e12 | 46 | I am going to shallow/deep sleep |
ccli8 |
1:eb1da9d36e12 | 47 | Wake up by <b>Unidentified</b> from <b>deep sleep</b> |
ccli8 |
1:eb1da9d36e12 | 48 | |
ccli8 |
1:eb1da9d36e12 | 49 | I am going to shallow/deep sleep |
ccli8 |
1:eb1da9d36e12 | 50 | Wake up by Button2 from <b>deep sleep</b> |
ccli8 |
1:eb1da9d36e12 | 51 | |
ccli8 |
1:eb1da9d36e12 | 52 | I am going to shallow/deep sleep |
ccli8 |
1:eb1da9d36e12 | 53 | Wake up by RTC alarm from <b>deep sleep</b> |
ccli8 |
1:eb1da9d36e12 | 54 | |
ccli8 |
1:eb1da9d36e12 | 55 | I am going to shallow/deep sleep |
ccli8 |
1:eb1da9d36e12 | 56 | Wake up by Button1 from <b>deep sleep</b> |
ccli8 |
1:eb1da9d36e12 | 57 | </pre> |
ccli8 |
1:eb1da9d36e12 | 58 | |
ccli8 |
1:eb1da9d36e12 | 59 | 1. If you see `shallow sleep` rather than `deep sleep`, you just enter **Idle** mode (shallow sleep) rather than |
ccli8 |
1:eb1da9d36e12 | 60 | **Power-down** mode (deep sleep). And you need to check your environment. |
ccli8 |
1:eb1da9d36e12 | 61 | 1. If you see `Unidentified`, it means chip is waken up from **Power-down** mode but its wake-up source is unidentified. |
ccli8 |
1:eb1da9d36e12 | 62 | Usually it is `lp_ticker` which is internal with the tickless mechanism. |
ccli8 |
1:eb1da9d36e12 | 63 | |
ccli8 |
1:eb1da9d36e12 | 64 | ## Known issues |
ccli8 |
8:acff1b7adc39 | 65 | 1. Since mbed OS **5.6.2**, `Ticker`, `Timeout`, and `Timer` could work correctly with this example. |
ccli8 |
8:acff1b7adc39 | 66 | But use of them would lock deep sleep and cause the system from entering into deep sleep mode. |
ccli8 |
8:acff1b7adc39 | 67 | It is because these timers rely on internal `us_ticker`, which relies on high-res clocks HXT/HIRC, |
ccli8 |
8:acff1b7adc39 | 68 | which are forced to stop in deep sleep mode to save more power. |
ccli8 |
8:acff1b7adc39 | 69 | To ensure these timers work correctly, the system is guarded from entering into deep sleep mode during their use. |
ccli8 |
1:eb1da9d36e12 | 70 | |
ccli8 |
8:acff1b7adc39 | 71 | 1. Use of interrupt callback and asynchronous transfer in `Serial`, `SPI`, `CAN`, etc. has the same issue as above. |
ccli8 |
8:acff1b7adc39 | 72 | |
ccli8 |
8:acff1b7adc39 | 73 | 1. Use of wait series functions (`wait`/`wait_ms`/`wait_us`) has the same issue as above. |
ccli8 |
8:acff1b7adc39 | 74 | During the wait time, the system is guarded from entering deep sleep mode. |
ccli8 |
8:acff1b7adc39 | 75 | |
ccli8 |
8:acff1b7adc39 | 76 | 1. Use of `EventQueue` has the same issue as above because `EventQueue` relies on `Timer`/`Ticker` for its internal counting. |
ccli8 |
8:acff1b7adc39 | 77 | |
ccli8 |
8:acff1b7adc39 | 78 | 1. Use of `RtosTimer` can work seamlessly with this example because `RtosTimer` relies on system timer rather than `us_ticker`. |