ISR compile error

Status
Not open for further replies.

John k2ox

Member
I has some code that compiles fine for a 328P. When I try to compile for Teensy 3.2 I get this error:

> spiSlaveTeensy:166: error: expected constructor, destructor, or type conversion before '(' token
> ISR(255)
> ^
> exit status 1
> expected constructor, destructor, or type conversion before '(' token



Here is the interrupt routine:

ISR(SPI_STC_vect)
{
// while (!(SPSR & _BV(SPIF))) ;

// digitalWrite(4, LOW);
c = SPDR;


while (!(SPSR & 1<<SPIF)) ;
c = (c << 8) | SPDR;

digitalWrite(4, LOW);
digitalWrite(4, LOW);
while (!(SPSR & 1<<SPIF)) ;
d = SPDR;

digitalWrite(4, LOW);
while (!(SPSR & 1<<SPIF)) ;
d = (d << 8) | SPDR;


spiDataAvailable = true;
interrupts();
}


The setup:

#include <SPI.h>

int clk = 13;
int dat = 11;
int ss = 10;
//volatile bool rLoad = false;
//volatile bool tLoad = false;
volatile boolean spiDataAvailable = false;
volatile uint16_t c, d;



void setup()
{
Serial.begin(250000);
delay(1000);
// pinMode(clk, INPUT);
//pinMode(dat, INPUT);
// pinMode(dat, INPUT_PULLUP);
pinMode(4, OUTPUT);

Serial.println("teensy 32b spi");
delay(100);

SPI.setDataMode (SPI_MODE0);
SPCR |= bit (SPE); // turn on SPI in slave mode

pinMode(10, OUTPUT);
digitalWrite(10, LOW);
SPI.attachInterrupt();
}

Your help is appreciated.

John
 
look at attachInterrupt()

ISR() is a macro from way back that is not per the Arduino/Teensyduino concepts.
 
This AVR only code would need to be rewritten. Teensy 3.x emulates some of the AVR SPI registers, for only for master mode.

Since your other thread says this code doesn't work anyway, let's continue this conversation on your other thread (and try not to start even more threads). I'm going to close this one.
 
Status
Not open for further replies.
Back
Top