Skip to content

Instantly share code, notes, and snippets.

@TheCrazyT
Created May 6, 2017 12:28
Show Gist options
  • Save TheCrazyT/9dc3e6dd31230b493ccf9b2e39fb5215 to your computer and use it in GitHub Desktop.
Save TheCrazyT/9dc3e6dd31230b493ccf9b2e39fb5215 to your computer and use it in GitHub Desktop.
#include <SPI.h>
void setup() {
Serial.begin(115200);
Serial.println("Test1");
pinMode(MISO, OUTPUT);
pinMode(SS, INPUT);
pinMode(SCK, INPUT);
pinMode(MOSI, INPUT);
SPCR |= _BV(SPE);
SPCR &= ~_BV(MSTR);
SPI.attachInterrupt();
}
// SPI interrupt routine
ISR (SPI_STC_vect)
{
Serial.println((char)SPDR);
//SPI.transfer('X'); //Enabling this line produces problems
} // end of interrupt routine SPI_STC_vect
void loop() {
}
#include <SPI.h>
void setup() {
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Test2");
SPI.begin();
//SPI.attachInterrupt(); //Enabling this line produces problems
}
// SPI interrupt routine
ISR (SPI_STC_vect)
{
Serial.println((char)SPDR);
}
void loop() {
SPI.transfer('A');
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment