This patch clears the EVENT_COMPARE register even when we're not
expecting to get a COMPARE interrupt.
Here is a scenario where we get an unwelcome interrupt, and where it
currently results in a deadlock:
* A Ticker T1 runs at 500ms
* Its handler registers a Timeout T2 at 20µs. Since LF clock runs at
32.768kHz, this will be rounded up to a multiple of 30.5µs (actually
61µs, to ensure we're in the next tick window)
T1 T2 T1' T2'
-------|---|---------------------------------|---|--------->
: : :
<---> n * 30.5µs :
<--------------- 500ms --------------->
* When the ticker API handles T1, it calls us_ticker_set_interrupt a
first time for T1', and then for registering T2.
* Since T2 period is less than one RTC tick (30.5µs), there is a high
chance it will go past *while* we're still in this first handler.
* So ticker_irq_handler also handles T2 as well, and removes it from the
queue.
* us_ticker_set_interrupt is called for T1' before returning from
ticker_irq_handler
The problem resides in the fact that us_ticker_set_interrupt takes more
than 2 RTC ticks to execute: while inside the handler, T2 interrupt will
fire.
* Because of this pending interrupt, RTC1_IRQHandler will be called
right away, but since we removed T2 from the queue, the handler is
waiting for T1' instead, and will not clear EVENT_COMPARE until we
reach the T1' tick, in about 500ms.
* This results in a lock and main isn't executed anymore.
With this patch, we avoid being stuck in RTC1_IRQHandler while waiting
for T1'.
Note: even when T2 isn't handled in the same loop as T1, we may get a
spurious interrupt, because us_ticker_set_interrupt will be called twice
for T2... and will register T2+m the second time, while T2 interrupt is
fired in the background.
That case isn't as harmful, since RTC1_IRQHandler will be waiting for
T2+m, which is only one or two ticks further, and then it won't be
called again before T1'.
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
|
||
|---|---|---|
| docs | ||
| libraries | ||
| travis | ||
| workspace_tools | ||
| .gitattributes | ||
| .gitignore | ||
| .travis.yml | ||
| CONTRIBUTING.md | ||
| LICENSE | ||
| MANIFEST.in | ||
| README.md | ||
| setup.py | ||
README.md
mbed SDK
The mbed Software Development Kit (SDK) is a C/C++ microcontroller software platform relied upon by tens of thousands of developers to build projects fast.
The SDK is licensed under the permissive Apache 2.0 licence, so you can use it in both commercial and personal projects with confidence.
The mbed SDK has been designed to provide enough hardware abstraction to be intuitive and concise, yet powerful enough to build complex projects. It is built on the low-level ARM CMSIS APIs, allowing you to code down to the metal if needed. In addition to RTOS, USB and Networking libraries, a cookbook of hundreds of reusable peripheral and module libraries have been built on top of the SDK by the mbed Developer Community.
Documentation
- Tools: how to setup and use the build system.
- mbed library internals
- Adding a new target microcontroller
Supported Microcontrollers and Boards
View all on the mbed Platforms page.
NXP:
- mbed LPC1768 (Cortex-M3)
- u-blox C027 LPC1768 (Cortex-M3)
- mbed LPC11U24 (Cortex-M0)
- EA LPC11U35 (Cortex-M0)
- mbed LPC2368 (ARM7TDMI-S)
- LPC2460 (ARM7TDMI-S)
- LPC810 (Cortex-M0+)
- LPC812 (Cortex-M0+)
- EA LPC4088 (Cortex-M4F)
- EA LPC4088 DM (Cortex-M4F)
- LPC4330 (Cortex-M4F + Cortex-M0)
- LPC1347 (Cortex-M3)
- LPC1114 (Cortex-M0)
- LPC11C24 (Cortex-M0)
- LPC1549 (Cortex-M3)
- LPC800-MAX (Cortex-M0+)
- DipCortex-M0 (Cortex-M0)
- DipCortex-M3 (Cortex-M3)
- BlueBoard-LPC11U24 (Cortex-M0)
- LPCCAPPUCCINO (Cortex-M0)
- Arch (Cortex-M0)
- Arch GPRS (Cortex-M0)
- Arch Pro (Cortex-M3)
Freescale:
- FRDM-KL05Z (Cortex-M0+)
- FRDM-KL25Z (Cortex-M0+)
- FRDM-KL43Z (Cortex-M0+)
- FRDM-KL46Z (Cortex-M0+)
- FRDM-K20D50M (Cortex-M4)
- FRDM-K22F (Cortex-M4F)
- FRDM-K64F (Cortex-M4F)
STMicroelectronics:
- Nucleo-F030R8 (Cortex-M0)
- Nucleo-F072RB (Cortex-M0)
- Nucleo-L053R8 (Cortex-M0+)
- Nucleo-F103RB (Cortex-M3)
- Nucleo-L152RE (Cortex-M3)
- Nucleo-F302R8 (Cortex-M4F)
- Nucleo-F334R8 (Cortex-M4F)
- Nucleo-F401RE (Cortex-M4F)
- Nucleo-F411RE (Cortex-M4F)
- STM32F4XX (Cortex-M4F)
- STM32F3XX (Cortex-M4F)
- STM32F0-Discovery (Cortex-M0)
- STM32VL-Discovery (Cortex-M3)
- STM32F3-Discovery (Cortex-M4F)
- STM32F4-Discovery (Cortex-M4F)
- STM32F429-Discovery (Cortex-M4F)
- STM32L0-Discovery (Cortex-M0+)
- Arch Max (Cortex-M4F)
Nordic:
- nRF51822-mKIT (Cortex-M0)
- Arch BLE (Cortex-M0)
Renesas:
- RZ-A1H (Cortex-A9)
Silicon Labs:
- [EFM32 Zero Gecko] (https://developer.mbed.org/platforms/EFM32-Zero-Gecko/) (Cortex-M0+)
- [EFM32 Happy Gecko] (https://developer.mbed.org/platforms/EFM32-Happy-Gecko/) (Cortex-M0+)
- [EFM32 Leopard Gecko] (https://developer.mbed.org/platforms/EFM32-Leopard-Gecko/) (Cortex-M3)
- [EFM32 Giant Gecko] (https://developer.mbed.org/platforms/EFM32-Giant-Gecko/) (Cortex-M3)
- [EFM32 Wonder Gecko] (https://developer.mbed.org/platforms/EFM32-Wonder-Gecko/) (Cortex-M4)
Supported Toolchains and IDEs
- GCC ARM: GNU Tools for ARM Embedded Processors
- ARMCC (standard library and MicroLib): uVision
- IAR: IAR Embedded Workbench
- GCC code_red: Red Suite
- GCC CodeSourcery: Sourcery CodeBench
- GCC ARM: Em::Blocks
- GCC ARM: CooCox CoIDE
API Documentation
- RTOS API
- TCP/IP Socket API (Transports: Ethernet, WiFi, 3G)
- USB Device API
- USB Host API
- DSP API
- Flash File Systems: SD, USB MSD, semihosted
- Peripheral Drivers API
Community
For discussing the development of the mbed SDK itself (Addition/support of microcontrollers/toolchains, build and test system, Hardware Abstraction Layer API, etc) please join our mbed-devel mailing list.
For every topic regarding the use of the mbed SDK, rather than its development, please post on the mbed.org forum, or the mbed.org Q&A.
For reporting issues in the mbed libraries please open a ticket on the issue tracker of the relevant mbed official library.
