Skip to content

Unexpected behaviour of the InterruptIn API on the Artemis Thing Plus #29

Open
@idea--list

Description

@idea--list

Description of defect

The InterruptIn API does not behave as expected on the Artemis Thing Plus board, while on the MAX32630FTHR the same code results in the expected behaviour.

Target(s) affected by this defect ?

Sparkfun Artemis Thing Plus (may be all the other Artemis boards as well but i can not test them)

Toolchain(s) (name and version) displaying this defect ?

Both ARMC6 and GCC_ARM (9-2019-q4-major)

What version of Mbed-os are you using (tag or sha) ?

Branch of the Mbed-Os-Ambiq-Apollo3 with ARMC6 support.

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

Mbed Studio 1.2

How is this defect reproduced ?

Compile the following code for the Artemis board:
#include "mbed.h" InterruptIn button(SW1, PullUp); DigitalOut led(LED_BLUE); void buttonFall() { led = 1; } void buttonRise() { led = 0; } int main() { button.fall(callback(buttonFall)); button.rise(callback(buttonRise)); while (1) { printf("Button state: %d\n", button.read()); } return 0; }

When run on the Artemis Thing Plus you will see the button state updating in the terminal window, however the led stays always on. It seems as if the interrupt handler functions would not have any effect, despite there is evidence about the state change in the instance of the InterruptIn object. This is unexpected.

If i compile the same code for my MAX32630FTHR then both the button state updates in the terminal window and also the led turns on and off as expected.

On the Artemis board i can use the following code to turn the led on and off, however by this way i am actually polling the state of the InterruptIn instance all the time and change the led's state from within the while loop in which case there is no sense in using any interrupts:
#include "mbed.h" InterruptIn button(SW1, PullUp); DigitalOut led(LED_BLUE); void buttonFall() { led = 1; } void buttonRise() { led = 0; } int main() { button.fall(callback(buttonFall)); button.rise(callback(buttonRise)); while (1) { printf("Button state: %d\n", button.read()); if (button.read() == 0) { led = 1; } else { led = 0; } } return 0; }

Metadata

Metadata

Assignees

No one assigned

    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