Skip to content

us_ticker_fire_interrupt: Event handler is never called #5051

Closed
@fkjagodzinski

Description

@fkjagodzinski

Description

  • Type: Bug
  • Priority: Major

Bug

Target
NUCLEO_F070RB, EFM32GG_STK3700

Toolchain
GCC_ARM, ARM, IAR

Toolchain version
GCC_ARM v6.3.1,
ARM uvision v5.24.2.0,
IAR IAR ANSI C/C++ Compiler V7.80.4.12462/W32 for ARM

mbed-cli version
1.2.0

mbed-os sha
814eaa9

Code

#include "mbed.h"
#include "hal/ticker_api.h"
#include "rtos.h"

Semaphore sem(0,1);

void foo(uint32_t id) {
    (void) id;
    sem.release();
}

int main() {
    ticker_event_t e;
    const ticker_data_t *us_td = get_us_ticker_data();
    ticker_set_handler(us_td, foo);
    ticker_insert_event_us(us_td, &e, 0, NULL);

    // As ticker_insert_event_us() is called with a timestamp earlier
    // than the current  -- us_td->interface->fire_interrupt is called.

    // sem should have been released by us_ticker_fire_interrupt()
    int32_t num_tokens = sem.wait(0);

    DigitalOut led1(LED1, 1);
    while (true) {
        if (num_tokens) {
            led1 = !led1;
        }
        wait(0.1);
    }
}

Expected behavior
The ticker event handler foo() is called immediately after ticker_insert_event_us().

Actual behavior
The ticker event handler foo is never called.

cc @bulislaw @0xc0170

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions