Comping error when setting up ISR() in arduino IDE (Teensy3.2)

Status
Not open for further replies.

Fsmer

New member
Hello everyone,
I trying to set up my own interrupt routine and not use AttachInterrupt() because I want to read out the interrupt flag to track the source.
When compiling this code and other example codes I get this same error:

SelfProgInterrupt:26: error: expected unqualified-id before '{' token
{

^

expected unqualified-id before '{' token

I noticed that in the core files the avr/interrupt.h is empty.
If anyone has a suggestion as to how to resolve this issue I'd be grateful to hear :)

Code:
#include <avr/io.h>
#include <avr/interrupt.h>

#define ISR(Vector)
int int_pin1 = 15;
int led = 13;
volatile byte state = HIGH;

void setup() {
  pinMode(int_pin1, INPUT);
  pinMode(led, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(int_pin1, INPUT_PULLUP);

}

void loop() {
  digitalWrite(12, HIGH);
  delay(100);
  digitalWrite(12, LOW);
  delay(100);

}

ISR(INT1_vect)
{
  state = !state;
}
 
Not sure you are on the right path but this should compile ???

if this is the right code spot - it needs void::
Code:
[COLOR="#FF0000"][B]void [/B][/COLOR]ISR(INT1_vect)
{
  state = !state;
}

Also needs a type on :: INT1_vect
<EDIT>:: Except _ISR's don't get params ...
 
Last edited:
The code change dit not work and with the original code it does compile for the Arduino Uno board.
Which still leaves me thinking I am missing the avr/interrupt.h file needed for the teensy3.
 
This is the syntax used for interrupts on AVR. But Teensy 3.2 is an ARM processor. This is the wrong way for ARM chips.
 
Here is a T3.2 sketch where you can define FASTISR to have the core transfer to your ISR on a pin interrupt. you are then responsible for figuring out which pin in PORTC interrupted and clearing the flag. The ISR in the sketch just clears all the PORTC interrupt bits. You need to look on the T3.2 schematic to determine the mapping of teensy pin to to PORTx

Code:
// jumper 23 to 22  scope on 23 and 12, adjust PWM rate til 12 falls behind
// FASTISR  optimize by direct ISR link

//#define FASTISR

// FASTRUN
void pin_isr() {
#ifdef FASTISR
  PORTC_ISFR = ~0;  //clear
#endif
  GPIOC_PTOR = CORE_PIN12_BITMASK;   // toggle
}
void setup() {
  pinMode(12, OUTPUT);
  attachInterrupt(22, pin_isr, CHANGE);
#ifdef FASTISR
  attachInterruptVector(IRQ_PORTC, pin_isr);
#endif
  //  NVIC_SET_PRIORITY(IRQ_PORTC, 0);   // pin 12 port C, reduce jitter?  nope
  analogWriteFrequency(23, 100000);
  analogWrite(23, 127);
}

void loop() {
}
 
Last edited:
Status
Not open for further replies.
Back
Top