Skip to content

configEdgeExint

gicking edited this page Feb 10, 2018 · 6 revisions

back to Command Reference / Digital-IO

Description

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 or INPUT_PULLUP_INTERRUPT via pinMode() or portMode()

Inclusion

  • 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

Syntax

configExintEdge(pPort, sensitivity);

Parameters

  • 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
  • output:

    • none

Returns

  • nothing

Example Code

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
}

Relevant Tutorial

Notes and Warnings

  • 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 or INPUT_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 and OUTPUT_OPENDRAIN, instead

See also

Clone this wiki locally