Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

SPI Slave Mode

SPI Slave Mode

2004-02-21 by Ivan Vernot

Hello All,
Does anyone have any experience with running an AVR (ATmega128) as an SPI slave?
I am using the onchip SPI port and have set the \SS (PB0) pin an input expecting to get an interrupt (SPIF set) when the SS pin gets asserted. This did not work.
Now I am polling the SS pin (PB0) and then reading the SPDR to get at the data.
According to Atmel spec (pg161) one should read the SPDR only after SPIF is set. so dutifully I do the following
while (!(SPSR & BIT(SPIF)))
{
WATCHDOG();
}
return (SPDR);
But it appears that SPIF in NOT being sent when data arrives INTO the micro when it is a slave.
ie. I get stuck in the while look forever!
Has anyone implemented a SPI slave (using the onchip SPI)? Could you share your experiences?
Thanks,
Ivan Vernot

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.