x-heep
x-heep copied to clipboard
example_gpio_intr not working on verilator
In #363 we added a second interrupt in the example_gpio_intr
application to test that the array of handlers inside the gpio hal was working.
At that time, that was working.
Note that both interrupts are exactly the same but with different handlers.
Symptoms
- Run
make run-app-verilator PROJECT=example_gpio_intr
- Open the terminal to see the output (e.g.
screen /dev/pts/x
, replacingx
for the screen reported in the terminal) - The output should be
Write 1 to GPIO 30 and wait for interrupt...
handler 1
Write 1 to GPIO 30 and wait for interrupt...
- The triggering of the second interrupt is not seen. We expect to see
handler 2
Success
at the end, but this never happens.
Things I have tried
- Changing the
uint8_t gpio_intr_flag
tovolatile
. → No change (but this change should be kept) - Shortening the
PRINTF
s at the beginning of each sequence →The secondPRINTF
is not printed. - Not triggering the second interrupt, but instead changing the flag → The program finishes successfully.
while(gpio_intr_flag == 0) {
CSR_CLEAR_BITS(CSR_REG_MSTATUS, 0x8);
gpio_intr_flag = 1; // <---------------
CSR_SET_BITS(CSR_REG_MSTATUS, 0x8);
}