This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Nested interrupt

Hi

Im using a timer to generate interrupt based on the match registers. On one of those interrupt, I would like to start a SPI data transfer. The SPI transfer is also using vector based interrupt (for sending 3 bytes).
But (of cause) the SPI interrupt doesnt work from within another VIC interrupt, so I guess I have to use nested interrupts??
Im looking at the nested interrupt sample from KEIL.
I guess I have todo the following:

timer_ISR
  IENABLE
  Start SPI transfer
  Do something else
  Ack the interrupt


SPI_ISR
  Send byte1
  Send byte2
  Send byte3
  IDISABLE
  Ack the interrupt


Is this the right approach?

Using af LPC2103 ARM7

/Thomas

Parents Reply Children
  • If you are going to busy-wait for the SPI transfer, then you should not run the SPI interface with interrupts.

    Instead, you should select the fastest working baudrate and then poll for your results. Interrupts are used when you do not want to poll. If you are going to poll anyway, then it is more efficient to just poll instead of having an interrupt receive the data and other code busy-waiting for the interrupt to report that the transfer is done.

    But the question is: Why do one interrupt handler need to send a number of bytes and then hang, waiting for the result? Why can't the results be stored by the SPI interrupt into a receive buffer and then consumed by a main loop?

  • Hi

    I did just that. I just start the SPI transfere in my timer interrupt. Then when SPI isr is saving the result for future use :-)