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 (17,790 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

 

 

Comments
by Visitor rrsquez@yahoo.com
on ‎01-03-2017 11:35 AM

Hello. I get the interrupt messages, but I cannot enable the output waveform.

 

Here is the original code snippet:

//     TimerSetup->Options |= (XTTCPS_OPTION_INTERVAL_MODE |XTTCPS_OPTION_MATCH_MODE|
//                               XTTCPS_OPTION_WAVE_DISABLE);

 

Here is how I modified it:
     TimerSetup->Options |= (XTTCPS_OPTION_INTERVAL_MODE |XTTCPS_OPTION_MATCH_MODE);
     TimerSetup->Options &= ~XTTCPS_OPTION_WAVE_DISABLE;

 

I also tried leaving out the previous line, but it still doesn't output my waveform. I mapped out pin R19 to pin 3 of CON 1 on the Breakout Carrier Card.

 

Can someone please tell me what I am doing wrong?

 

Thank you, Richard V

by Observer taylo_ap
on ‎01-03-2017 12:27 PM

Richard

 

Thanks for reading the series, I actually had the TTC going yesterday and generating a PWM output using the code attahced from here the only thing I changed was remove the wave disable and add in the polarity change. 

 

Rememeber the wave changes when the counter = match register what value did you have set in that?

 

TimerSetup->Options |= (XTTCPS_OPTION_INTERVAL_MODE |XTTCPS_OPTION_MATCH_MODE|XTTCPS_OPTION_WAVE_POLARITY);

 

Let me know if you having any issues there is video of PWM being used here https://www.youtube.com/watch?v=VkSmoirdmfc

 

Adam 

by Visitor rrsquez@yahoo.com
on ‎01-03-2017 03:10 PM

Hello Adam. Sorry, but I don't see anything on Pin 3 of CON1 on the BCC. This maps out to pin R19 on the MicroZed. I'm using an oscilloscope to look at the pin. 

 

Here is my constraint file:

set_property PACKAGE_PIN R19 [get_ports {My_Wave_Out}]
set_property IOSTANDARD LVCMOS33 [get_ports {My_Wave_Out}]
set_property PULLUP true [get_ports {My_Wave_Out}]

 

My_Wave_Out is the name I used when I made this output port.

 

The rest is your code. I've been spending all day on this with no good results. The blog doesn't follow the latest version of Vivado, so I'm guessing when following those steps. Is it possible that in figuring out the block diagram on my own that I messed something up?

 

That link you sent me was of no help. All I see are two servo motors turning; no code, no explanation. Was that the correct link?

 

Thank you, Richard

by Visitor rrsquez@yahoo.com
on ‎01-03-2017 03:21 PM

Hello Adam. I already tried all of what you mentioned beforehand. 

 

This my Utilization Report:

| R19 | My_Wave_Out | High Range | IO_0_34 | OUTPUT | LVCMOS33 | 34 | 12 | SLOW | | FP_VTT_50 | | FIXED | PULLUP | | | NONE

 

R19 is Pin 3 of CON 1 on the BCC. I just followed the instructions, and used the code snippet you gave me, but I still don't get a waveform. Did you actually see this pin toggling with an O-scope? I'm using one and I don't see anything on that pin.

 

Thank you, Richard V

by Observer taylo_ap
on ‎01-04-2017 11:41 AM

Richard,

 

Is it possible you can post your block diagram from vivado here?

 

If you want to zip your project and send it to me at aptaylor@theiet.org I would be happy to look at it, sure we can get you going Smiley Happy  

 

Regards

 

Adam 

by Visitor rrsquez@yahoo.com
on ‎01-04-2017 02:59 PM

Hello Adam. Thank you for taking the time to look. I'm using Vivado v2016.4. The example works, except that I can't turn on the waveform to view. 

 

I'd like to see how that PWM example was created. All I saw was a demonstration, but no coding.

 

Thank you, Richard V

 

 

Tutorial_24_Block_Diagram.jpg

by Observer taylo_ap
on ‎01-04-2017 04:03 PM

Richard

 

That does not look any different to what I was expecting, can you email me at the above address and I will help get you going. 

 

Adam 

Labels
About the Author
  • Be sure to join the Xilinx LinkedIn group to get an update for every new Xcell Daily post! ******************** Steve Leibson is the Director of Strategic Marketing and Business Planning at Xilinx. He started as a system design engineer at HP in the early days of desktop computing, then switched to EDA at Cadnetix, and subsequently became a technical editor for EDN Magazine. He's served as Editor in Chief of EDN Magazine, Embedded Developers Journal, and Microprocessor Report. He has extensive experience in computing, microprocessors, microcontrollers, embedded systems design, design IP, EDA, and programmable logic.