I have recently experimented with changing the interrupt vector priority level of a SAML21 SERCOM, used as a SPI Master, to a lower level.
The SPI is used to connect external flash.
Since lowering the priority the SPI is suffering from SERCOM_SPI_STATUS_BUFOVF events.
This results in the SPI_INTERRUPT_FLAG_RX_COMPLETE callback not being called.
The fact higher priority interrupts can interrupt the _spi_interrupt_handler is understood, but I don't think it should overflow.
I think the _spi_interrupt_handler in sam0/drivers/sercom/spi/spi_interrupt.c should do a read-before-write operation.
That is:
/* Receive complete interrupt*/ if (interrupt_status & SPI_INTERRUPT_FLAG_RX_COMPLETE) { ... }
before:
/* Data register empty interrupt */ if (interrupt_status & SPI_INTERRUPT_FLAG_DATA_REGISTER_EMPTY) { .... }
In my testing this eliminated the SERCOM_SPI_STATUS_BUFOVF.
Am I on a sensible track?
If so, and it is considered a bug\improvement to ASF3, what are the next steps?