Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<SPI.h>
- char buf[100];
- byte c=0,b=0;
- volatile byte pos;
- volatile boolean processing;
- byte i;
- void setup(void) {
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode(MISO,OUTPUT);
- pinMode(MOSI,INPUT);
- SPCR |= _BV(SPE);
- pos = 0;
- processing = false;
- SPI.attachInterrupt();
- }
- ISR(SPI_STC_vect){
- c = SPDR;
- // SPDR = 0x55;
- // if(pos<20){
- // buf[pos++] = c;
- // if(c == '\n')
- // processing=true;
- // }
- processing = true;
- }
- void loop(void) {
- // put your main code here, to run repeatedly:
- if(processing){
- // Serial.println("Inside Processing");
- Serial.println(c);
- processing = false;
- SPDR = i;
- i = i+1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment