Skip to content

InterruptIn rise/fall methods overwrite pullup/pulldown mode for STM32F4 targets #2638

Closed
@andreaslarssonublox

Description

@andreaslarssonublox

The gpio_irq_set function calls pin_function with GPIO_NOPULL.

The code below was used to generate the issue on an STM32F429i-DISCO board using the DISCO_F429ZI target. If the mode method is called after rise/fall it works as expected.

`

include <stdio.h>

include <string.h>

include "mbed.h"

InterruptIn button(PF_2);
DigitalOut led1(LED1);
DigitalOut led2(LED2);

void handleRise() {
led1 = 1;
led2 = 0;
}

void handleFall() {
led1 = 0;
led2 = 1;
}

int main() {
button.mode(PullUp); // Set PF_2 to pullup. GPIOF->PUPDR=0x00000010 -> OK
button.rise(&handleRise); // Will overwrite the mode. GPIOF->PUPDR=0x00000000 -> Not OK
button.fall(&handleFall); // Will overwrite the mode. GPIOF->PUPDR=0x00000000 -> Not OK
while (1) {
wait(0.25);
}
}
`

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