I have an STM32L development board set up with Chibi 2.6.6.
I am installing an EXT driver on GPIOA1 for falling edge transitions. Inside of the EXT interrupt handler's callback that I have implemented, I immediately disable the EXT channel, and set a vtimer for 500ms. My idea is to debounce the circuit triggering the interrupt. When the vtimer expires, I re-enable the EXT channel.
My question is, if I hold down the button (and watching on my scope, I can tell the pin stays at 0v), as soon as the EXT channel is enabled again, I immediately get another interrupt. Ie. If I hold the button for 10 seconds, I will have gotten about 20 interrupts. Is this normal? I would have expected it needs an edge transition for the interrupt to fire again.
Do I need to set the GPIOA-1 pin up specifically with palSetPadMode() ?
EXT Interrupt question
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: EXT Interrupt question
Hi,
The pin just needs to not be in analog mode.
I think the HW takes the enabling of the edge with the button pressed as an edge, this is why the interrupt is triggered again. Try verifying the behavior on the reference manual.
Giovanni
The pin just needs to not be in analog mode.
I think the HW takes the enabling of the edge with the button pressed as an edge, this is why the interrupt is triggered again. Try verifying the behavior on the reference manual.
Giovanni
Re: EXT Interrupt question
Hey Giovanni,
I didn't find anything in the ref manual wrt what you suggested. However, if I remove my attempt at "software debounce" (ie. do not disable the EXT channel, or arm the timer) and I hold down the button, I get hundreds of calls to my ext callback handler.
I tried explicity setting PA1 to PAL_MODE_INPUT (even though it should be that way at reset) and the problem persists.
Also, before it is asked, yes I removed the kits LCD so that PA1 is not tied to it.
Any other ideas?
I didn't find anything in the ref manual wrt what you suggested. However, if I remove my attempt at "software debounce" (ie. do not disable the EXT channel, or arm the timer) and I hold down the button, I get hundreds of calls to my ext callback handler.
I tried explicity setting PA1 to PAL_MODE_INPUT (even though it should be that way at reset) and the problem persists.
Also, before it is asked, yes I removed the kits LCD so that PA1 is not tied to it.
Any other ideas?
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: EXT Interrupt question
This is weird because EXT is edge sensitive, if you keep it down there should be no edges. Could it be a noise problem?
Giovanni
Giovanni
Re: EXT Interrupt question
As usual once you dig a little deeper you find out your assumptions were wrong 
The part I left out for simplicity is that my "button" is actually going through a MCP23017 (i2c <-> GPIO) chip and PA1 is tied to the interrupt pin of that device. The MCP23017 is running at 5v, and even though PA1 is 5v tolerant, I'm sure it's edge detection transition is in the 1-2 volt range. I had my scope trigger set a little too high to notice the glitches (rookie mistake
.
At any rate, the problem seems to lie in my court not ChibiOS. I was pretty sure the MCP23017 configuration I am using would not regenerate the interrupt, but it seems to be glitching when I read its status register. If I disable that read, and the interrupt pin goes low and stays low, ChibiOS only calls my callback one time so it is working as expected.
Thanks as always,
Dave
The part I left out for simplicity is that my "button" is actually going through a MCP23017 (i2c <-> GPIO) chip and PA1 is tied to the interrupt pin of that device. The MCP23017 is running at 5v, and even though PA1 is 5v tolerant, I'm sure it's edge detection transition is in the 1-2 volt range. I had my scope trigger set a little too high to notice the glitches (rookie mistake
At any rate, the problem seems to lie in my court not ChibiOS. I was pretty sure the MCP23017 configuration I am using would not regenerate the interrupt, but it seems to be glitching when I read its status register. If I disable that read, and the interrupt pin goes low and stays low, ChibiOS only calls my callback one time so it is working as expected.
Thanks as always,
Dave
Re: EXT Interrupt question
Hi
I want to use EXT as rising edge but when I change EXT demo file to rising edge or falling edge it gets error. Is there any other configuration which I missed?(I'm using STM32F3&4)
I want to use EXT as rising edge but when I change EXT demo file to rising edge or falling edge it gets error. Is there any other configuration which I missed?(I'm using STM32F3&4)
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: EXT Interrupt question
I just changed demo file like this:
...
static const EXTConfig extcfg = {
{
{EXT_CH_MODE_RISING_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, extcb1},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
...
and I got this error:
"Compiling main.c
main.c:50:6: error: 'EXT_CH_MODE_RISING_EDGES' undeclared here (not in a function)
{EXT_CH_MODE_RISING_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, extcb1},
^
main.c:74:1: warning: missing initializer for field 'channels' of 'EXTConfig' [-Wmissing-field-initializers]
};
^
In file included from ../../../../os/hal/include/ext.h:74:0,
from ../../../../os/hal/include/hal.h:49,
from main.c:18:
../../../../os/hal/ports/STM32/LLD/ext_lld.h:106:25: note: 'channels' declared here
EXTChannelConfig channels[EXT_MAX_CHANNELS];
^
make: *** [build/obj/main.o] Error 1"
...
static const EXTConfig extcfg = {
{
{EXT_CH_MODE_RISING_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, extcb1},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
...
and I got this error:
"Compiling main.c
main.c:50:6: error: 'EXT_CH_MODE_RISING_EDGES' undeclared here (not in a function)
{EXT_CH_MODE_RISING_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, extcb1},
^
main.c:74:1: warning: missing initializer for field 'channels' of 'EXTConfig' [-Wmissing-field-initializers]
};
^
In file included from ../../../../os/hal/include/ext.h:74:0,
from ../../../../os/hal/include/hal.h:49,
from main.c:18:
../../../../os/hal/ports/STM32/LLD/ext_lld.h:106:25: note: 'channels' declared here
EXTChannelConfig channels[EXT_MAX_CHANNELS];
^
make: *** [build/obj/main.o] Error 1"
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times