Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

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

  1. #1
    Junior Member
    Join Date
    Jun 2019
    Posts
    2

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

    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;
    }

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    8,792
    Not sure you are on the right path but this should compile ???

    if this is the right code spot - it needs void::
    Code:
    void ISR(INT1_vect)
    {
      state = !state;
    }
    Also needs a type on :: INT1_vect
    <EDIT>:: Except _ISR's don't get params ...
    Last edited by defragster; 06-13-2019 at 04:59 PM.

  3. #3
    Junior Member
    Join Date
    Jun 2019
    Posts
    2
    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.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,169
    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.

  5. #5
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,999
    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 by manitou; 06-14-2019 at 09:55 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •