Simple SPI Interrupt Question

Thread Starter

meiya777

Joined Jun 28, 2008
3
I have 3 atmega8 boards, one as master and two as slaves.

My question is on the slaves board:

If a slave is working on something else (in fact that one of the slaves must keep reading reading DAC), how does it know if there's data send by the master? Do I have to keep checking certain port? Or how to trigger like external interrupt?
 

retched

Joined Dec 5, 2009
5,207
In your ADC loop, you can check for a handshake on SPI. When it is, it can jump out of the loop, recieve, transmit, and RETURN to the ADC loop.
 

eblc1388

Joined Nov 28, 2008
1,542
If a slave is working on something else (in fact that one of the slaves must keep reading reading DAC), how does it know if there's data send by the master? Do I have to keep checking certain port? Or how to trigger like external interrupt?
You don't need to check periodically or wire up external interrupt.

SPI operation has its own interrupt flag. If you setup the M8 AVR to allow for SPI interrupt, then a completed SPI transfer to the slave will automatically generate an interrupt to get you attention.
 

retched

Joined Dec 5, 2009
5,207
Thats right. The SPI inerrupt will handle incoming requests from the master. Setting up the code to handle the inturrupt should be listed in the datasheet.

Good call eblc1388.
 
Top