Simple SPI Interrupt Question

Discussion in 'Embedded Systems and Microcontrollers' started by meiya777, Apr 28, 2010.

  1. meiya777

    Thread Starter New Member

    Jun 28, 2008
    3
    0
    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?
     
  2. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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.
     
  3. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    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.
     
    meiya777 likes this.
  4. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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.
     
  5. meiya777

    Thread Starter New Member

    Jun 28, 2008
    3
    0
    I got it. Thanks a lot.
     
Loading...