Arty – Interrupts Part Two – AXI Timer

Facebooktwittergoogle_plusredditpinterestlinkedinmail

In the last blog we had successfully instantiated the interrupt controller and demonstrated it functioning as intended by simulating the timer interrupt.

The next step is to configure the timer and demonstrate that the interrupts can be handled properly from the timer in reality.

What I want to be able to do using the AXI Timer is measure the interrupt latency of the MicroBlaze. Interrupt latency—the time between the interrupt being raised and the interrupt being serviced—plays a large role in performance. A number of issues impact interrupt latency, two of these issues are the presence of an operating system and the complexity of the ISR (Interrupt Service Routine).

However the underlying hardware and processor architecture will also have an impact on the interrupt latency time. We can use the AXI Timer to help us measure this time however, first we need to get the AXI Timer up and running.

The AXI Timer contains two 32 bit timer which can be configured in the following modes

  • Generate – The counter counts up or down as selected from a reset value, once the terminal count is reached the generate output is pulsed and the interrupt if enabled is generated. This mode is used to generate a signal or interrupt at a predefined time interval
  • Capture – The assertion of the external trigger signal stores the value of the counter when the signal is asserted. This can be used to measure the duration of external events.
  • PWM – Uses both timers to create a PWM signal – timer 0 defines the overall period and timer 1 defines the high time of the period.

As you can see the AXI timer is a very useful component to our embedded system, what is important for measuring the interrupt latency is the ability to assert the freeze input which stops the counter.

1

The timer can be configured to operate as either an up or down counter and in our application is clocked from the UI_CLK output from the MIG. This clock frequency is 83.25MHz or ¼ of the DDR Controller rate.
For this example and the interrupt latency we will use the timer in the generate mode such that it generates at a predefined period, we will be using the counter in its default count up mode.

The periodic time is defined by loading in a predefined value

Period = ( 2^32-1 – Reset Value + 2) * Clk Period

We will use a Reset Value of 0xF0000000 with an 83.25 MHz clock results in a period of 3.22 seconds between interrupts.

The interrupt service routine will be configured to print out that the interrupt has occurred and restart the counter. I have added the code example code to the Github repository when I ran the code on my Arty board I got the result below.

2

In the next blog we will look at how we can use the timer in more detail to determine the interrupt latency and the potential methods we can use to do this.

Facebooktwittergoogle_plusredditpinterestlinkedinmail