Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPIOTE interrupt not triggering after it was enabled #277

Closed
hannes-hochreiner opened this issue Dec 29, 2020 · 0 comments
Closed

GPIOTE interrupt not triggering after it was enabled #277

hannes-hochreiner opened this issue Dec 29, 2020 · 0 comments

Comments

@hannes-hochreiner
Copy link
Contributor

hannes-hochreiner commented Dec 29, 2020

I was trying to configure an input pin to trigger an interrupt. Following the example, I set up the pin and the gpiote.

let drdy_pin = port0.p0_30.into_floating_input().degrade();
let gpiote = Gpiote::new(device.GPIOTE);
gpiote.channel0().input_pin(&drdy_pin).hi_to_lo().enable_interrupt();

However, the interrupt never triggers.

Looking at the source code, the problems seems to be that the pin number is written to the intenset and intenclr registers.

 pub fn enable_interrupt(&self) -> &Self {
        unsafe {
            self.gpiote
                .intenset
                .modify(|r, w| w.bits(r.bits() | self.pin.pin() as u32))
        }
        self
}

According to the Nordic documentation the register has a bit field for the channels. Therefore, it should be more like:

 pub fn enable_interrupt(&self) -> &Self {
        unsafe {
            self.gpiote
                .intenset
                .modify(|r, w| w.bits(r.bits() | 1 << self.channel as u32))
        }
        self
}

Same goes for disabling the interrupt.
I'll test later and prepare a PR. Feel free to assign the issue to me.

jonas-schievink added a commit that referenced this issue Jan 4, 2021
Fix #277 (re)setting GPIOTE interrupts for channels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant