I'm confused by some symptoms that I've got on my Atmega2560 using avr-gcc 4.7.2 so I thought I'd ask the collective expects here for advice.
What I see looks as though execution of my SPI interrupt (SPI_STC_vect) appears to prevent service of my uart RX (USART0_RX_vect)
- I appreciate that the SPI_STC_vect has a higher priority than that USART0_RX_vect given its address
- but I would expect any waiting uart interrupt to be serviced when the SPI interrupt returned: which is not what I appear to see
On my SPI I have a SPI-Uart bridge with a fifo (SC16IS752 from NXP)
- this pulls an IRQ line attached to pinchange irpt on the 2560 when its buffer hits a threshold
- then I pull out the required bytes via code in the SPI_STC_vect
Attaching a logic analyser and toggling leds at the relevant parts I can see that my interrupt on the SPI takes between 20-50us to execute (system clocked at 8MHz)
- after which there is about 20us before it is entered again: during this time I can see the transaction happen on the SPI data lines (SPI clock at 4MHz)
- depending on how I have configured the chip I could be pulling up to 60bytes here: which would be ~70 interrupts
My problem is that during the entire sequence in and out of the SPI interrupt, no interrupts are serviced on the on-chip uart (incoming serial at 9600baud)
- code at USART0_RX_vect does not execute at all
- with a line thrown during the uart RX code I can see that during traffic it is rock solid regular until the SPI transactions start (taking 26us to execute)
- it does not get triggered again until the SPI handling is completed (all 70 interrupt executions)
Halting code during the SPI interrupt (using AVR studio 6.2) I can confirm that my UCSROB = 0xC1
- showing that my Uart0 receiver is enabled along with the receive complete interrupt enable
- thus I would expect that on returning from the SPI interrupt, that any waiting UART interrupt would execute
At present I've worked around this by configuring the bridge chip to request a service after 4 bytes (thus completing in less than one char on the chip uart)
- but for my peace of mind however I'd rather understand why this is not working as I would have expected
Is there something else I should look at to see if I can't get these interrupts to interleave?
- anything in a 2560 register that I might have missed?
Thanks for any suggestions,
All the best,