Hi,
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 (status_pin.read() == 1) return;
local result = 1
BR.pin.write(SS_ENABLE)
result = SPI.readblob(1)
BR.pin.write(SS_DISABLE)
server.log("M") //Log statement to check I enter the interrupt handler
server.log(result[0])
}`
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.