Imp Reading from AtmelMega328


I was wondering if anyone tried to interface with the AtmelMega328 via SPI? Currently I have it configured such that my Atmel will be able to interrupt the Imp with an active low signal (So IMP is the master and Atmel is the slave). I want to be able to read a byte of data (status data) from the Atmel at this time. I have tried the following, but I only read 00 on the IMP side.

IMP code:
function interruptHandler () {
// ignore the rising edge (since we only care about falling edge)
if ( == 1) return;

local result = 1
result = SPI.readblob(1)

server.log("M") //Log statement to check I enter the interrupt handler 


And on the Atmel side I have:
PORTB &= ~(1 << 7); //Drive pin low to trigger interrupt _delay_ms(1000); spi_write(0x55); //Write 0x55, so ideally want to be able to read this on the IMP side _delay_ms(1000); PORTB |= (1 << 7); //Drive pin back high

Any thoughts and insight really appreciated! Or if anyone could direct me to an article with some code snippet? Thanks.

I don’t believe the Arduino supports SPI slave with the libraries - you have to hit the hardware directly. eg see

Note also that timing is driven by the imp as master. Even when you do do slave mode, you’d need to buffer your 0x55 data before driving the pin low as the imp could start clocking at any moment - you definitely can’t wait 1 second there.

…this is why people tend to prefer UARTs. They’re much easier to deal with!

You were right I was having an timing issue, thanks!