Hi @Jonny040 I am not familiar with MultiZone but maybe these few notes can shed some light on your question.
The interrupt handling procedural flow is a detailed discussion and good diagram here in the forums.
A very lean yet complete working example is Demonstrating MTVEC on my github site.
In general there’s only a few simple steps:
Assuming you’ve set up mtvec
properly, enabled the CSR’s mstatus.MIE
bit, and enabled the appropriate bit of GPIO_IE,
a) Read PLIC_CLAIM to get the source id
of the interrupt request – the 32 GPIO are id’s 8-39
b) Write PLIC_CLAIM to complete the request of that source
c) Jump to desired code
d) Write ‘1’ to appropriate bit of GPIO_IP to clear the pending interrupt
e) Exit with the mret
instruction
You don’t need to clear the mstatus.MIP
bit, because it is cleared automatically when mret
happens.
The specific method of clearing external interrupts varies depending on the nature of the external peripheral whose interrupt you enable; step (d) above is shown in case of GPIO. See the procedural flow discussion above for clearing, for example, the UART, the SPI, the I2C, or the PWM periperals.