By Adam Taylor

Now that the Adafruit NeoPixel example has been completed (see my eight previous blog posts, below), we’ll be moving on for a look at operating systems. But first, a short interlude. During the past week I received an interesting question about Part 24 of this blog that discussed communication across the Zynq SoC’s PS/PL (processor system/programmable logic) interface. The particular question related to raising an interrupt to an ARM Cortex-A9 MPCore CPU in the Zynq PS from the PL.

Here’s a block diagram of the ARM GIC (Generic Interrupt Controller) within the Zynq SoC’s PS, taken from the Zynq -7000 All Programmable SoC Technical Reference Manual (UG585):

The diagram above shows that each CPU has a number of shared interrupts from the PL to the PS (16 interrupts) and five private interrupts for each CPU core from the PL. These interrupt sources drive a fast interrupt and a regular interrupt for each CPU core. In this example, I show how to use the private interrupt. However the general concept is the same regardless of interrupt used. For this example, I will be using an EMIO GPIO pin connected via the PL, looped back and connected to the processor’s interrupt pin. A simple software program can then demonstrate how an interrupt from the PL works. Note: The interrupt at the PL/PS interface is active high, not active low.

The first stage of this example is to enable the interrupts between the PL and PS and to enable the specific interrupt you wish to use.

The second step is to enable a single-bit GPIO using the EMIO option.

Both the interrupt and the GPIO pin will now appear on the Zynq PS block within the block diagram. These signals can be then be interconnected, so that we can drive the interrupt from the EMIO within the Zynq PL under software control.

Having gotten to this stage, the next step is to regenerate all of the output products for the design and implement the design so that we can export it to the SDK. In turn, this allows us to write the code to test the application.

Our test application will trigger an FPGA interrupt when we press the push-button switch on the MicroZed board.

Within the SDK, we need to perform the following steps:

Declare the following header files: Platform.h, xparameters.h, Xscugic.h, Xil_Exceptions.h and xgpio.h. These header files will provide functions and macros that enable us to generate the example. Define the generic interrupt controller and GPIO device ID and interrupt numbers along with the FPGA interrupt and pin numbers for the EMIO and push-button switch. Declare and write a number of required functions:

Interrupt controller set up function

PGA Interrupt handler, which prints a message

GPIO Interrupt handler, which drives the EMIO GPIO to trigger a FPGA interrupt upon a push-button interrupt.

The attached code (see attachment below, at the end of this blog post) shows in detail exactly how how I implemented this simple example. However, I think I should explain the way I set up the interrupt for the FPGA in a little more detail.

When setting up an interrupt in the Zynq we need to do the following things:

Initialize the Interrupt controller. Connect the exception ID to the associated handler so that when an event occurs it can be run correctly. Connect the FPGA interrupt to the generic interrupt controller. This requires the pre-defined interrupt ID, the call-back handler (which is defined to identify the source of the interrupt), and the interrupt service routine to be run when the interrupt occurs. Enable the interrupt on the interrupt controller. Enable interrupts on the processor.

The above flow is required for one interrupt or for many interrupts, with points 3 and 4 repeated for each interrupt required.

When I ran this code on my MicroZed and pushed the button, I saw the following response:

It works.

Please see the previous entries in this MicroZed series by Adam Taylor:

Adam Taylor’s MicroZed Chronicles Part 37: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 8

Adam Taylor’s MicroZed Chronicles Part 36: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 7

Adam Taylor’s MicroZed Chronicles Part 35: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 6

Adam Taylor’s MicroZed Chronicles Part 34: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 5

Adam Taylor’s MicroZed Chronicles Part 33: Driving Adafruit RGB NeoPixel LED arrays with the Zynq SoC

Adam Taylor’s MicroZed Chronicles Part 32: Driving Adafruit RGB NeoPixel LED arrays

Adam Taylor’s MicroZed Chronicles Part 31: Systems of Modules, Driving RGB NeoPixel LED arrays

Adam Taylor’s MicroZed Chronicles Part 30: The MicroZed I/O Carrier Card

Zynq DMA Part Two – Adam Taylor’s MicroZed Chronicles Part 29

The Zynq PS/PL, Part Eight: Zynq DMA – Adam Taylor’s MicroZed Chronicles Part 28

The Zynq PS/PL, Part Seven: Adam Taylor’s MicroZed Chronicles Part 27

The Zynq PS/PL, Part Six: Adam Taylor’s MicroZed Chronicles Part 26

The Zynq PS/PL, Part Five: Adam Taylor’s MicroZed Chronicles Part 25

The Zynq PS/PL, Part Four: Adam Taylor’s MicroZed Chronicles Part 24

The Zynq PS/PL, Part Three: Adam Taylor’s MicroZed Chronicles Part 23

The Zynq PS/PL, Part Two: Adam Taylor’s MicroZed Chronicles Part 22

The Zynq PS/PL, Part One: Adam Taylor’s MicroZed Chronicles Part 21

Introduction to the Zynq Triple Timer Counter Part Four: Adam Taylor’s MicroZed Chronicles Part 20

Introduction to the Zynq Triple Timer Counter Part Three: Adam Taylor’s MicroZed Chronicles Part 19

Introduction to the Zynq Triple Timer Counter Part Two: Adam Taylor’s MicroZed Chronicles Part 18

Introduction to the Zynq Triple Timer Counter Part One: Adam Taylor’s MicroZed Chronicles Part 17

The Zynq SoC’s Private Watchdog: Adam Taylor’s MicroZed Chronicles Part 16

Implementing the Zynq SoC’s Private Timer: Adam Taylor’s MicroZed Chronicles Part 15

MicroZed Timers, Clocks and Watchdogs: Adam Taylor’s MicroZed Chronicles Part 14

More About MicroZed Interrupts: Adam Taylor’s MicroZed Chronicles Part 13

MicroZed Interrupts: Adam Taylor’s MicroZed Chronicles Part 12

Using the MicroZed Button for Input: Adam Taylor’s MicroZed Chronicles Part 11

Driving the Zynq SoC's GPIO: Adam Taylor’s MicroZed Chronicles Part 10

Meet the Zynq MIO: Adam Taylor’s MicroZed Chronicles Part 9

MicroZed XADC Software: Adam Taylor’s MicroZed Chronicles Part 8

Getting the XADC Running on the MicroZed: Adam Taylor’s MicroZed Chronicles Part 7

A Boot Loader for MicroZed. Adam Taylor’s MicroZed Chronicles, Part 6

Figuring out the MicroZed Boot Loader – Adam Taylor’s MicroZed Chronicles, Part 5

Running your programs on the MicroZed – Adam Taylor’s MicroZed Chronicles, Part 4

Zynq and MicroZed say “Hello World”-- Adam Taylor’s MicroZed Chronicles, Part 3

Adam Taylor’s MicroZed Chronicles: Setting the SW Scene

Bringing up the Avnet MicroZed with Vivado