Is there a good way to trigger an interrupt from a write operation on the K22F? My goal is specifically this: I've got an external SPI NOR flash that's slow to erase. During the erase cycle, it has to be constantly polled for completion, and that can take a large fraction of a second. Rather than set up a periodic interrupt to check up on the progress, I'd prefer to have a DMA channel keep feeding the poll command to SPI and have the result written somewhere that it'll trigger an interrupt as soon as the 'busy' bit in the result clears.
Even if there's nothing specifically designed for that (the ARM Cortex M NVIC manual mentions a Software Trigger Interrupt Register that sounds promising) there are enough peripherals with configurable interrupts and maybe some extra flexibility from the aliased bit-band regions that there *must* be a way to generate an interrupt based on that one changing bit.
Thanks,
Scott
Hi, Scott,
I see your scheme that you want to write the SPI received data to a palce via DMA which can trigger an interrupt when one bit in the SPI received data is one.
This is my opinion, I think you can use GPIO to implement the scheme. You can connect one GPIO pin of one port to another GPIO pin of another port, and set first GPIO pin as GPIO and output mode, configure the second GPIO as GPIO input and interrupt enable for rising edge. You can use DMA to transfer the received to a GPIO data register, once the bit in the received data register becomes one, the first GPIO pin will become one, which will trigger an interrupt for the second GPIO pins which is configured as GPIO input and interrupt enabled.
Hope it can help you
BR
Xiangjun Rong
That was my first thought as well, but it doesn't help for already-built hardware. We did once have a board that as part of a rework procedure we had to deliberately add a solder bridge between two pins, but I'd rather not have to do that again. =]
I was a little disappointed to discover that the DMA controller apparently can't access aliased bit band regions, so that limits some of the stupid tricks available but I think I can still make it work.
The MK22FN1M0AVLH12 has only 3 accessible UARTs, but there are at least 4 on the die. As a test, I enabled UART3, enabled its error interrupt in the NVIC, and did a dummy read on UART3_D to cause a FIFO underflow. Bit 0 of CFIFO can then be used to trigger an interrupt.
NVICSTIR is the closest thing to what I was originally looking for, but it's not usable for what I want and it's not accessible to the DMA controller anyway.
The hidden UART offers some interesting possibilities with the 'match address' function with loopback mode enabled.
Anyway, I've killed enough time on this for one morning. I think my answer is that yes, it's possible to generate interrupts based on incoming DMA data, but maybe not in a universally-applicable way.
Thanks,
Scott