I like the way artificial intelligence works, but I like the way it works. I like the way it works, and I like the way it works. I like the way it works, and I like the way it works

Before actually playing Zynq interrupts, let’s talk about the magic of interrupts

Real-time is a very important performance of an embedded system. Real-time is reflected in the response ability and processing ability of a system to external events, and the RESPONSE and processing of CPU to an event mainly depends on —interrupt.

In layman’s terms, a basic process of interruption is: When an event occurs (such as a button press), generates a signal can be sent to the CPU interrupt (along the rising or falling doesn’t matter, is a signal line), when the CPU receives the interrupt signal, to deal with of what is said in the interrupt signal (jump to the interrupt service program, to deal with button press this event).

An interrupt system model is abstracted from this basic process as shown in the figure below:

In the figure above is just an interrupt signal, so when the systemThere are a lot of interruption signals“, leaderless, the whole system will be chaotic, the CPU will be like a headless fly everywhere to execute interrupt service procedures, the result can be imagined, the CPU will be able to do nothing at last ~

To solve this problem, you need to assign a leader to manage these various interruptions, and that manager is —Interrupt management unit! So, it only has one function —Manage these interrupt signals! Such asEnable and disable— Which interrupt signals to pass and which signals not to pass; “priority“– Who passes first and who passes last, the improved model is shown below:

This way, the CPU can only receive an interrupt signal, so the CPU can comfortably do what it needs to do.

  • Configure peripherals to generate interrupt signals
  • Configure interrupt management unit, enable signal through, (configure signal priority)
  • Configure interrupt service routines to ensure that the CPU can process interrupt signals in a timely manner

Next, use this abstract interrupt model to play with Zynq’s interrupts and externalize the model

1. Purpose of the experiment

To explore the ZynqPL->PSThe key is pressed to generate an interrupt, which is processed by the universal Interrupt management unit and passed to Zynq PS, which increments the variable value and displays it on the LED.

2. Experimental procedures

2.1. Create a project based on PYNQ-Z2

2.2. Create a hardware block design

2.2.1. Add the used IP and automatically connect

Add two AXI_GPIOip cores, one connecting the board with 4 buttons and one connecting the board with 4 leds

2.2.2. Configure AXI_GPIO to enable interrupts

Here, because the four keys are connected to AXI_gPIo_0, double-click axi_gPIo_0 IP core to configure, as shown in the picture, select Enable interrupt:

You can see the difference from axi_gPIo_1 with no interrupt configured:

2.2.2. Configure Zynq PS to receive interrupt requests

Before configuration, you need to have a general understanding of the interrupt signals in Zynq. The interrupt signals between PS and PL are shown in the following table:

According to the figure above, double-click the Zynq IP core to configure, because the key interrupts that need to be received are from PL to PS, selected firstFabric InterruptsBreak the organization, then selectIRQ_F2P[15:0].Enable the 16-bit PL->PS shared interrupt portSo that interrupts from the PL side can be connected to the PS interrupt controller:

2.2.3. Connect AXI_GPIO interrupt request to PS interrupt port

Manual connection:

2.3. Verify the design, create HDL files, generate Bitstream, and export the hardware design files

At this point, the hardware data path of interrupt signal is completed, followed by the configuration of interrupt management unit and interrupt service program in the software.

2.4. Transition to software design on SDK

Against 2.4.1. Launch the SDK

2.4.2. Create an empty application project

2.4.3. Import an existing C file

Because the division of labor is needed in the actual project, the C file attached with the book is selected here:

2.4.4. Configure running Settings and board-level verification

Run to observe the phenomenon.