Enable and check the interrupt mechanism using the command-line (or skip to GUI version).
1. Check the LED's register can be written & read back from. This time use devmem instead of peek & poke.
root@petalinux:~# devmem 0x40010000 w 0x18
root@petalinux:~# devmem 0x40010000
0x00000018
All being well LED's 3 & 4 should illuminate with the first command and the second command should return the written value of 0x18.
2. Set the
Global Interrupt Enable Register inside the Programmable Logic (PL)
AXI GPIO Zed module.
root@petalinux:~# devmem 0x4001011c w 0x80000000
3. Enable interrupts for
Channel 3 (Push Buttons) by setting the 3rd bit of the
Interrupt Enable Register.
root@petalinux:~# devmem 0x40010128 w 0x4
The interrupt mechanism is now ready.
4. Press and release one of the Push Buttons on the Zedboard.
5. Check the Kernel for an interrupt. All being well the interrupt counter should have incremented by 1 indicating that an interrupt has occurred.
root@petalinux:~# cat /proc/interrupts | grep axi_gpio_zed
53: 1 0 GIC-0 61 Edge axi_gpio_zed
6. Determine which GPIO Channel the interrupt occurred on by reading the
Interrupt Status Register. Should show
Channel 3 (3rd bit set).
root@petalinux:~# devmem 0x40010120
0x00000004
7. Determine which Push Button was pressed by reading
Channel 3's Data Register. 0x2 indicates the down button.
root@petalinux:~# devmem 0x40010010
0x00000002
8. Clear
Channel 3's Data Register.
root@petalinux:~# devmem 0x40010010 w 0x0
9. Rearm
Channel 3's interrupt by clearing its set bit (toggle-on-write) in the
Interrupt Status Register.
root@petalinux:~# devmem 0x40010120 w 0x4
10. Rearm the Kernel interrupt by writing a 1 to the device.
root@petalinux:~# echo 0x1>/dev/uio0
Steps 4 through 10 can now be repeated. Each iteration should show an incremented count for the
axi_gpio_zed interrupt.
An Interrupt can be generated without pressing a button by simply setting a bit in the
Interrupt Status Register (this is handled in exactly the same way as a Push Button generated interrupt).
11. Clear the
Global Interrupt Enable Register.
root@petalinux:~# devmem 0x4001011c w 0x00000000
12. Disable interrupts for
Channel 3 by clearing the 3rd bit in the
Interrupt Enable Register.
root@petalinux:~# devmem 0x40010128 w 0x0