I think the best website describing in details how to use Arduino library for SPI communication is from Nick Gammon Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino
Much work he's done explaining details of SPI functionality and providing many usable examples. Same great work he's done regarding other comm protocols too. Such individuals like Nick are the movers behind the arduinozation of the world
Using those examples in my application I came across this :
describing changes between old and new SPI routines this is mentioned:
These functions should not be used because SPI is waiting on the interrupt bit to be set in the hardware register:
- SPI.attachInterrupt() // do not use*
- SPI.detachInterrupt() // do not use*
When I remove SPI.attachInterrupt() from SPI slave code (Arduino Nano acting as SPI slave) it fails. Apparently SPI ISR routine is not getting called.
Either including SPI.attachInterrupt() or this line SPCR |= _BV(SPIE); would make code function again.
Seems in the new SPI library either one of these lines attaching interrupt to AVR register is needed for SPI ISR routine to be called for the SPI event.
Looks like that note above should be removed.