| tmrctr Vitis Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions
xtmrctr_intr_example.c File Reference

## Overview

This file contains a design example using the timer counter driver (XTmCtr) and hardware device using interrupt mode.This example assumes that the interrupt controller is also present as a part of the system.

This file can be used as a standalone example or by the TestAppGen utility to include a test for Timer interrupts.

     MODIFICATION HISTORY:

     Ver   Who  Date         Changes

     1.00b jhl  02/13/02 First release
     1.00b sv   04/26/05 Minor changes to comply to Doxygen and coding guidelines
     1.00b sn   05/09/06 Modified to be used by TestAppGen to include test for
                          interrupts.
     2.00a ktn  10/30/09 Updated to use HAL API's and minor changes as per coding
                          guidelines.
     2.00a ssb  01/11/01 Updated the example to be used with the SCUGIC in
                          Zynq.
     4.2   ms   01/23/17 Added xil_printf statement in main function to
                         ensure that "Successfully ran" and "Failed" strings
                         are available in all examples. This is a fix for
                         CR-965028.
     4.5   mus  07/05/18 Updated example to call TmrCtrDisableIntr function
                         with correct arguments. Presently device id is
                         being passed instead of interrupt id. It fixes
                         CR#1006251.
     4.5   mus  07/05/18 Fixed checkpatch errors and warnings.
     4.9   mus  11/26/21 Existing example shows incorrect behavior if it
                         gets included in peripheral test, and targeted HW
                         design has more than one AXI timer instances. This
                         is due to TimerExpired variable, which is shared
                         between interrupt context and main thread. As it
                         is not getting initialized to 0 for subsequent
                         TmrCtrIntrExample calls, interrupt example test for 2nd
                         and subsequent AXI timer instances would be passed
                         without generating interrupts. It fixes CR#1116308.
     4.12  ml   12/07/23 Make TimerExpired as a static variable.
     4.12  mus  03/25/24 Update RESET_VALUE to reduce extecution time to 1 seconds.

## Functions
int | TmrCtrIntrExample (INTC *IntcInstancePtr, XTmrCtr *TmrCtrInstancePtr, u16 DeviceId, u16 IntrId)
| This function does a minimal test on the timer counter device and driver as a design example. More...
int | main (void)
| This function is the main function of the Tmrctr example using Interrupts. More...

## Function Documentation

int main | ( | void |  | ) |

This function is the main function of the Tmrctr example using Interrupts.

Parameters

  None. |

Returns
  XST_SUCCESS to indicate success, else XST_FAILURE to indicate a Failure.

Note
  None.

References TmrCtrIntrExample().

int TmrCtrIntrExample | ( | INTC * | IntcInstancePtr,
|  | XTmrCtr * | TmrCtrInstancePtr,
|  | u16 | DeviceId,
|  | u16 | IntrId
| ) |  |

This function does a minimal test on the timer counter device and driver as a design example.

The purpose of this function is to illustrate how to use the XTmrCtr component. It initializes a timer counter and then sets it up in compare mode with auto reload such that a periodic interrupt is generated.

This function uses interrupt driven mode of the timer counter.

Parameters

  IntcInstancePtr | is a pointer to the Interrupt Controller driver Instance
  TmrCtrInstancePtr | is a pointer to the XTmrCtr driver Instance
  DeviceId | is the XPAR_<TmrCtr_instance>_DEVICE_ID value from xparameters.h
  IntrId | is XPAR_<INTC_instance>_<TmrCtr_instance>_INTERRUPT_INTR value from xparameters.h
  TmrCtrNumber | is the number of the timer to which this handler is associated with.

Returns
  XST_SUCCESS if the Test is successful, otherwise XST_FAILURE

Note
  This function contains an infinite loop such that if interrupts are not working it may never return.

References XTmrCtr::Config, TimerCounterHandler(), XTmrCtr_Initialize(), XTmrCtr_InterruptHandler(), XTmrCtr_SelfTest(), XTmrCtr_SetHandler(), XTmrCtr_SetOptions(), XTmrCtr_SetResetValue(), XTmrCtr_Start(), and XTmrCtr_Stop().

Referenced by main().