Skip to content

Fire interrupt function broken for nrf5x targets #5284

Closed
@0xc0170

Description

@0xc0170

Description

  • Type: Bug
  • Priority: Minor

Bug

Target
Any nrf51 possibly

Toolchain:
Any

Expected behavior

Tickers (us or lp) should set pending bit and ticker irq handler should be instantly called.

Actual behavior

Test fails (no callback is called). If I replace fire_interrupt with invoking directly isr ticker handler, then it works.

+--------------+---------------+-------------------------------+-----------------------------------+--------+--------+--------+--------------------+
| NRF51_DK-ARM | NRF51_DK      | tests-mbed_drivers-timerevent | Test insert                       | 1      | 0      | OK     | 0.09               |
| NRF51_DK-ARM | NRF51_DK      | tests-mbed_drivers-timerevent | Test insert zero                  | 1      | 0      | OK     | 0.04               |
| NRF51_DK-ARM | NRF51_DK      | tests-mbed_drivers-timerevent | Test insert_absolute              | 1      | 0      | OK     | 0.1                |
| NRF51_DK-ARM | NRF51_DK      | tests-mbed_drivers-timerevent | Test insert_absolute zero         | 0      | 1      | FAIL   | 0.08               |
| NRF51_DK-ARM | NRF51_DK      | tests-mbed_drivers-timerevent | Test remove after insert          | 1      | 0      | OK     | 0.2                |
| NRF51_DK-ARM | NRF51_DK      | tests-mbed_drivers-timerevent | Test remove after insert_absolute | 1      | 0      | OK     | 0.21               |
+--------------+---------------+-------------------------------+-----------------------------------+--------+--------+--------+--------------------+
mbedgt: test case results: 1 FAIL / 5 OK

Steps to reproduce

Fetch this patch - #5046, run tests and should see the failure.

This is nrf5 targets implementation for us ticker fire intterupt on master currently:

void us_ticker_fire_interrupt(void)
{
    uint32_t closest_safe_compare = common_rtc_32bit_ticks_get() + 2;
    nrf_rtc_cc_set(COMMON_RTC_INSTANCE, US_TICKER_CC_CHANNEL, RTC_WRAP(closest_safe_compare));
    nrf_rtc_event_enable(COMMON_RTC_INSTANCE, US_TICKER_INT_MASK);
}

This I believe should be for nrf51822 unified targets (on master it's not complete):

void us_ticker_fire_interrupt(void)
{
    uint32_t newCallbackTime = rtc1_getCounter() + FUZZY_RTC_TICKS;
    NRF_RTC1->CC[0]             = newCallbackTime & MAX_RTC_COUNTER_VAL;
    us_ticker_callbackTimestamp = newCallbackTime;
    us_ticker_callbackPending = true;
    rtc1_enableCompareInterrupt();
}

cc @nvlsianpu @anangl @pan-

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions