Sure, so the SPI slave was not working on the atmega328 with the INIT SPI provided
after a bit of research, I found a way to initialize it with some C-code
I am not 100% sure the init code is as it has to be. but at least now something is working
Hope that Matrix will fix it, the following is the init code to make SPI slave work on the 328P
.
Code: Select all
// Set MISO as output
DDRB |= (1 << PB4); // MISO
// MOSI, SCK, SS as input
DDRB &= ~((1 << PB3) | (1 << PB5) | (1 << PB2));
// Enable SPI and configure as Slave
SPCR = (1 << SPE); // Enable SPI in Slave mode, MSTR is cleared automatically for slave
What I am trying to do for Testing is ,
1: Master sends char 79
2: Slave receives 1 Char 79 --> send it back master (79) and then also send char 75
3: Master receive 2 Chars and send them out via rs232
But there is something odd the slave is not transmitting the data in the right sequence
and Master should be receiving 79 and 75 not 79 and 85
.