I'm trying to perform SPI data transfer between RaspberryPi 3 (master) and blank ATmega32U4 (slave).
Here are both slave/master code:
// ****** Master ********
unsigned char a;
// ********* Slave *********
ISR(SPI_vect) // Interrupt function
// Blink a led during transfer
PORTF &= ~(1<<PF5);
command = SPDR;
SPDR = command+1;
DDRF = (1<<PF5);
DDRB = (1<<PB3);
SPCR &= ~(1<<MSTR);
SPCR |= (1<<SPE) | (1<<SPIE);
PORTF |= (1<<PF5);
At the execution of master code, the slave shut the led and stay "blocked". It seems that code stop after the first call of in the interrupt function. After that, every byte from ATmega is 0.
From the things we know:
- The ATmega chip is flashed with AVRISP from the RaspberryPi with ATmega SS pin connected on CEO pin on raspberry, i don't think hardware is the problem.
- The first call of the interrupt slave function comes with after calling "wiringPiSPISetup". If the function is not called, then nothing happen at all. After that, trig the ATmega reset pin make the led shine again but SPI interface is not responding, interruption function is never called, even after re-run the master program.
- I have to reupload .hex file to retry.
The ATmega32u4 fuses are E:FB H:D9 L:FF
Did I miss something ?