diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/lp_ticker.c b/targets/TARGET_NUVOTON/TARGET_M2351/lp_ticker.c index 8e0daf379f..d7b4eb6e47 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/lp_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_M2351/lp_ticker.c @@ -101,8 +101,6 @@ void lp_ticker_init(void) /* By HAL spec, ticker_init allows the ticker to keep counting and disables the * ticker interrupt. */ lp_ticker_disable_interrupt(); - lp_ticker_clear_interrupt(); - NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); return; } ticker_inited = 1; @@ -203,6 +201,10 @@ timestamp_t lp_ticker_read() void lp_ticker_set_interrupt(timestamp_t timestamp) { + /* Clear any previously pending interrupts */ + lp_ticker_clear_interrupt(); + NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); + /* In continuous mode, counter will be reset to zero with the following sequence: * 1. Stop counting * 2. Configure new CMP value diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/us_ticker.c b/targets/TARGET_NUVOTON/TARGET_M2351/us_ticker.c index a8034561fc..9a336110c7 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/us_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_M2351/us_ticker.c @@ -75,8 +75,6 @@ void us_ticker_init(void) /* By HAL spec, ticker_init allows the ticker to keep counting and disables the * ticker interrupt. */ us_ticker_disable_interrupt(); - us_ticker_clear_interrupt(); - NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); return; } ticker_inited = 1; @@ -159,6 +157,10 @@ uint32_t us_ticker_read() void us_ticker_set_interrupt(timestamp_t timestamp) { + /* Clear any previously pending interrupts */ + us_ticker_clear_interrupt(); + NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); + /* In continuous mode, counter will be reset to zero with the following sequence: * 1. Stop counting * 2. Configure new CMP value diff --git a/targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c b/targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c index 5a09e84a3d..98e8631e4e 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c @@ -76,8 +76,6 @@ void lp_ticker_init(void) /* By HAL spec, ticker_init allows the ticker to keep counting and disables the * ticker interrupt. */ lp_ticker_disable_interrupt(); - lp_ticker_clear_interrupt(); - NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); return; } ticker_inited = 1; @@ -166,6 +164,10 @@ timestamp_t lp_ticker_read() void lp_ticker_set_interrupt(timestamp_t timestamp) { + /* Clear any previously pending interrupts */ + lp_ticker_clear_interrupt(); + NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); + /* In continuous mode, counter will be reset to zero with the following sequence: * 1. Stop counting * 2. Configure new CMP value diff --git a/targets/TARGET_NUVOTON/TARGET_M451/us_ticker.c b/targets/TARGET_NUVOTON/TARGET_M451/us_ticker.c index 0fadea09de..66e9a97c42 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/us_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/us_ticker.c @@ -52,8 +52,6 @@ void us_ticker_init(void) /* By HAL spec, ticker_init allows the ticker to keep counting and disables the * ticker interrupt. */ us_ticker_disable_interrupt(); - us_ticker_clear_interrupt(); - NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); return; } ticker_inited = 1; @@ -124,6 +122,10 @@ uint32_t us_ticker_read() void us_ticker_set_interrupt(timestamp_t timestamp) { + /* Clear any previously pending interrupts */ + us_ticker_clear_interrupt(); + NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); + /* In continuous mode, counter will be reset to zero with the following sequence: * 1. Stop counting * 2. Configure new CMP value diff --git a/targets/TARGET_NUVOTON/TARGET_M480/lp_ticker.c b/targets/TARGET_NUVOTON/TARGET_M480/lp_ticker.c index 1811c72dfc..04b88e8a61 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/lp_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/lp_ticker.c @@ -76,8 +76,6 @@ void lp_ticker_init(void) /* By HAL spec, ticker_init allows the ticker to keep counting and disables the * ticker interrupt. */ lp_ticker_disable_interrupt(); - lp_ticker_clear_interrupt(); - NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); return; } ticker_inited = 1; @@ -166,6 +164,10 @@ timestamp_t lp_ticker_read() void lp_ticker_set_interrupt(timestamp_t timestamp) { + /* Clear any previously pending interrupts */ + lp_ticker_clear_interrupt(); + NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); + /* In continuous mode, counter will be reset to zero with the following sequence: * 1. Stop counting * 2. Configure new CMP value diff --git a/targets/TARGET_NUVOTON/TARGET_M480/us_ticker.c b/targets/TARGET_NUVOTON/TARGET_M480/us_ticker.c index 1441cf26b3..715857241d 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/us_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/us_ticker.c @@ -52,8 +52,6 @@ void us_ticker_init(void) /* By HAL spec, ticker_init allows the ticker to keep counting and disables the * ticker interrupt. */ us_ticker_disable_interrupt(); - us_ticker_clear_interrupt(); - NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); return; } ticker_inited = 1; @@ -124,6 +122,10 @@ uint32_t us_ticker_read() void us_ticker_set_interrupt(timestamp_t timestamp) { + /* Clear any previously pending interrupts */ + us_ticker_clear_interrupt(); + NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); + /* In continuous mode, counter will be reset to zero with the following sequence: * 1. Stop counting * 2. Configure new CMP value diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c b/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c index c2faafc856..fc249fc38e 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c @@ -78,8 +78,6 @@ void lp_ticker_init(void) /* By HAL spec, ticker_init allows the ticker to keep counting and disables the * ticker interrupt. */ lp_ticker_disable_interrupt(); - lp_ticker_clear_interrupt(); - NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); return; } ticker_inited = 1; @@ -170,6 +168,10 @@ timestamp_t lp_ticker_read() void lp_ticker_set_interrupt(timestamp_t timestamp) { + /* Clear any previously pending interrupts */ + lp_ticker_clear_interrupt(); + NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); + /* In continuous mode, counter will be reset to zero with the following sequence: * 1. Stop counting * 2. Configure new CMP value diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/us_ticker.c b/targets/TARGET_NUVOTON/TARGET_NANO100/us_ticker.c index 0c5160d839..f1bf49467e 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/us_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/us_ticker.c @@ -54,8 +54,6 @@ void us_ticker_init(void) /* By HAL spec, ticker_init allows the ticker to keep counting and disables the * ticker interrupt. */ us_ticker_disable_interrupt(); - us_ticker_clear_interrupt(); - NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); return; } ticker_inited = 1; @@ -126,6 +124,10 @@ uint32_t us_ticker_read() void us_ticker_set_interrupt(timestamp_t timestamp) { + /* Clear any previously pending interrupts */ + us_ticker_clear_interrupt(); + NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); + /* In continuous mode, counter will be reset to zero with the following sequence: * 1. Stop counting * 2. Configure new CMP value diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c b/targets/TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c index 1f55c08ca2..c7972dcabd 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c @@ -76,8 +76,6 @@ void lp_ticker_init(void) /* By HAL spec, ticker_init allows the ticker to keep counting and disables the * ticker interrupt. */ lp_ticker_disable_interrupt(); - lp_ticker_clear_interrupt(); - NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); return; } ticker_inited = 1; @@ -165,6 +163,10 @@ timestamp_t lp_ticker_read() void lp_ticker_set_interrupt(timestamp_t timestamp) { + /* Clear any previously pending interrupts */ + lp_ticker_clear_interrupt(); + NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); + /* In continuous mode, counter will be reset to zero with the following sequence: * 1. Stop counting * 2. Configure new CMP value diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/us_ticker.c b/targets/TARGET_NUVOTON/TARGET_NUC472/us_ticker.c index 03e58bac60..a135a7585a 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/us_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/us_ticker.c @@ -52,8 +52,6 @@ void us_ticker_init(void) /* By HAL spec, ticker_init allows the ticker to keep counting and disables the * ticker interrupt. */ us_ticker_disable_interrupt(); - us_ticker_clear_interrupt(); - NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); return; } ticker_inited = 1; @@ -123,6 +121,10 @@ uint32_t us_ticker_read() void us_ticker_set_interrupt(timestamp_t timestamp) { + /* Clear any previously pending interrupts */ + us_ticker_clear_interrupt(); + NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n); + /* In continuous mode, counter will be reset to zero with the following sequence: * 1. Stop counting * 2. Configure new CMP value