Forum Discussion
Altera_Forum
Honored Contributor
12 years agoI suggest that you read the documentation for the PIO. It is here (http://www.altera.com/literature/ug/ug_embedded_ip.pdf), chapter 10. On the hardware level you will need to be sure that the component is configured to generate an interrupt on edge capture. I think that by default it will generate one on level.
You are right that you put your code in your handle_my_interrupt() routine. Before returning you will need to clear the edge cap register, as explained on page 10-8, or else the interrupt will fire right away again. It is best practise (especially if you are working with a real time OS) to have your interrupt routine as small and fast as possible, to avoid disturbing the rest of the software. That means that if you do the SPI reading from the interrupt routine, you shouldn't poll the SPI master to wait for the answer, but use the SPI's interrupt system instead.