-
Notifications
You must be signed in to change notification settings - Fork 7
configEdgeExint
gicking edited this page Feb 10, 2018
·
6 revisions
back to Command Reference / Digital-IO
Function to set the edge sensitivity for the external port interrupt (EXINT). Note that for port interrupts, all 8 port pins share the same edge sensitivity.
Notes:
- after reset edge sensitivity of all ports is
LOW
. To avoid stalling the device in case of a static low pin, change edge sensitivity prior to enabling the external interrupt. - to enable an external interrupt, the respective pin has be configured as
INPUT_INTERRUPT
orINPUT_PULLUP_INTERRUPT
via pinMode() or portMode()
- defined in
gpio.h
- auto-loaded in
main_general.h
- in
config.h
set#define USE_PORTx_ISR
(x=A..F
) for the respective GPIO port. For each activated port, a respective interrupt service routine PORTx_ISR() is required. - for the
TLI
capable pin, e.g.PD7
, use command configEdgeTLI() and TLI_ISR() instead
configExintEdge(pPort, sensitivity);
-
input:
- pPort: address of port to configure, e.g.
&PORT_A
- sensitivity: edge sensitivity to set
-
LOW
: EXINT on low level. Warning: can stall device on pin static low -
CHANGE
: EXINT on both edges -
RISING
: EXINT on rising edge -
FALLING
: EXINT on falling edge
-
- pPort: address of port to configure, e.g.
-
output:
- none
- nothing
The below code counts the number of falling edges on pin PE5 (without debounce).
#include "main_general.h"
uint16_t count=0;
ISR_HANDLER(PORTE_ISR, __PORTE_VECTOR__) {
count++;
}
void setup()
{
noInterrupts();
configEdgeExint(&PORT_E, FALLING);
pinMode(&PORT_E, 5, INPUT_PULLUP_INTERRUPT);
interrupts();
}
void loop()
{
// dummy
}
- before changing the edge sensitivity, globally disable interrupts via noInterrupts(). Re-enable them afterwards via interrupts().
- to use EXINTs the respective pins must also be configured as
INPUT_INTERRUPT
orINPUT_PULLUP_INTERRUPT
via pinMode() or portMode() - use port edge sensitivity
LOW
with care, e.g. disable EXINT in ISR. Else a port pin with static low level can stall the device
To avoid damage
- do not expose I/Os to voltages outside [-0.3V; Vdd+0.3V], else limit injection currents to the specificied limits
- for
OUTPUT
pins assert that sink and source currents are below the specificied limits - do not directly connect two
OUTPUT
pins. If e.g. half-duplex is required, use a pull-up andOUTPUT_OPENDRAIN
, instead
-
Getting Started
-
- General Commands
- Libraries
- LCD BTHQ21605V
- poti AD5280
- poti AD5282
- freemodbus
- PetitFS SD-card (min)
- FatFS: SD card (full)
- Board Specific
-
- Universal
- Board Specific