We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
I just have to add, that the call to SPI_Read is blocking until the 3 bytes are send. I guess I cant get the SPI interrupts before the timer ISR has ack'ed the interrupt?
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?
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 :-)