Go Down

Topic: SPI interrupt (Read 1 time) previous topic - next topic

Gibson486

What is the SPI interrupt handler on the Due? On the Mega, it was ISR (SPI_STC_vect){}, but this does not seem to work on the Due.

Magician

I think ,  SPI_Handler(void)
http://asf.atmel.com/docs/latest/sam.drivers.spi.example.sam3u_ek/html/spi__example_8c.html#a362497e8f44dbb1f6b5d0deb68eb1ff1

Gibson486


I think ,  SPI_Handler(void)
http://asf.atmel.com/docs/latest/sam.drivers.spi.example.sam3u_ek/html/spi__example_8c.html#a362497e8f44dbb1f6b5d0deb68eb1ff1


I tried that, but it did not work.....

MarkT

The Due processor is about 50 times more complex than the ATmega328, some
study of the (very large) datasheet is necessary to come to terms with it, allow a
few days for studying it I reckon.

I'd read the general intro, then the SPI section, then read the Arduino runtime
code for its SPI handling (which uses libsam, which you also have source code for).
Find and study examples too.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Gibson486

#4
Jul 30, 2014, 04:08 pm Last Edit: Jul 30, 2014, 04:33 pm by Gibson486 Reason: 1
I got it to work.....

You are right, it is more complex....

What I did probably is frowned upon. I simply attached the interrupt manually, then called my own function in the attachInterrupt() function. In the function I wrote to the SPI buffer register. It worked for my preliminary purposes, but it always gives me trash on the first byte I send. To fix this, I just take a reading twice and ignore the first reading.  I suspect it is happening because I am writing to the register while the SPI clock on the master is going. Unfortunately, I am not sure how to delay the clock on the master (a MCP2210 chip). But, it works for now!!!! Of course...I run into problems when I want to do a data transfer that is more than 8 bits long. .....

Go Up