UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

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

by Xilinx Employee on ‎02-18-2014 08:51 AM (192,582 Views)

When we last looked at the Zynq SoC’s TTC (Triple Timer Counter), we had configured one of the three timers within TTC to operate in simple interval mode generating an interrupt at the desired frequency. However we can use the TTC to do much more than that, so in this final blog post looking at the TTC, I thought I would explore the TTC’s more complex uses.

 

We will look at using the match registers to issue interrupts for different counter values. This discussion will then enable us to easily generate an output waveform. When the waveform output is enabled, its output inverts when the match value matches the counter value.

 

The first step is to enable the match mode within the timer set up options. We can OR the XTTCPS_OPTION_MATCH_MODE as defined within the xttcps.h file to enable the match mode along with the disabled waveform and interval mode.

 

Having set the match mode the next steps are very simple configure the match register with value we wish to trigger the interrupt at using the function below.

 

XTtcPs_SetMatchValue(&Timer, 0, (interval/3));

 

In the example above, the match value of match register one is defined to trigger at one third of the value defined within the interval counter. I have used the function XTtcPs_GetInterval()to access the value of the interval counter.

 

The next step is to enable the match interrupt. In this example, we only need to enable match interrupt one but can use the definitions provided within xttcps.h again

 

XTtcPs_EnableInterrupts(TtcPsInt, XTTCPS_IXR_MATCH_0_MASK);

 

Within the interrupt service routine (ISR), we then need to determine the cause of the interrupt (because the routine can be called for the interval interrupt as well). We can determine what event caused the interrupt pretty easily by performing a AND operation between the interrupt status register and the interrupt definitions.

 

 

if (0 != (XTTCPS_IXR_MATCH_0_MASK & StatusEvent)) {

printf("match interrupt event\n\r");

}

 

 

This allows the ISR to take different actions depending upon the source of the interrupt. In this case, the action is to print a different message over STDOUT.

 

 

STDOUT.jpg

 

 

If we decide to output the waveform it is as simple as enabling the waveform output within the TTC option registers and double checking that the TTC output is correctly connected to the selected Zynq output pin. The polarity can also be selected using the XTTCPS_OPTION_WAVE_POLARITY option.

 

Other advanced TTC uses include a create a Real Time Clock (RTC), with the TTC configured to produce an interrupt at the required time resolution and then increase the count each time the interrupt occurs. An RTC can be very useful in embedded systems with one example being the time stamping of system events.

 

This wraps up looking at the TTC. I hope you have found it interesting.

 

 

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

 

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