Koduino
Functions
External interrupts

Detailed Description

Usage

  1. Call attachInterrupt()

Example: Mass transport sensor

#include <Arduino.h>
// Change to whatever pin an LED is connected to
const int led = PC13;
// Declare variables that will be modified by interrupt handlers `volatile`
volatile int count = 0;
void countUp() {
count++;
}
void setup() {
Serial1.begin(115200);
attachInterrupt(PA0, countUp, CHANGE);
}
void loop() {
Serial1 << "Counted " << count << " particles.\n";
delay(100);
}

Functions

void attachInterrupt (uint8_t pinName, ISRType ISR, InterruptTrigger mode)
 Enable an interrupt with default priority. More...
 
void detachInterrupt (uint8_t pinName)
 Disable an interrupt. More...
 
void noInterrupts ()
 Disable external interrupts. More...
 
void interrupts ()
 Enable external interrupts. More...
 

Function Documentation

void attachInterrupt ( uint8_t  pinName,
ISRType  ISR,
InterruptTrigger  mode 
)

Enable an interrupt with default priority.

Note: There is only ONE EXTI per pinSource, i.e. PA0, PB0 cannot both have interrupts, but PA0 and PB1 can. Obviously, there can be a total of 16.

Parameters
pinNameName of pin interrupt is connected to
ISRCallback function to call when interrupt is triggered
modeOne of InterruptTrigger
void detachInterrupt ( uint8_t  pinName)

Disable an interrupt.

Parameters
pinNamePin name where attachInterrupt() was called
void interrupts ( )

Enable external interrupts.

Enabled by default

void noInterrupts ( )

Disable external interrupts.

Note: This is unlike the Arduino function which disables ALL interrupts. That would stop the system clock here as well. Call NVIC_DisableIRQ() if you want the arduino behavior