Nios® V Processor Software Developer Handbook

ID 743810
Date 2/14/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

3.4.3.1.2. Timestamp Timer

The timestamp timer service provides applications with an accurate way to measure the duration of an event in the system. The default timestamp timer in a Nios® V processor subsystem is the Nios® V processor built-in internal counter. You may alternatively configure the system clock timer to other timer peripherals in the Platform Designer system.

Note: Only one timestamp timer service may be identified in the BSP library file. Only HAL supplied routines access the timer.

The hal.timestamp_timer setting controls the BSP configuration for the timer. This setting configures one of the timers available in the Platform Designer design as the timestamp timer.

Intel provides a timestamp API. The timestamp API is very simple. It includes the alt_timestamp_start() function, which makes the timer operational, and the alt_timestamp() function, which returns the current timer count.

Consider the following common issues and important points before you implement a timestamp timer:

  • Timer Frequency—The timestamp timer decrements at the clock rate of the clock that feeds it in the Platform Designer system. You can modify this frequency in Platform Designer.
  • Rollover—The timestamp timer has no rollover event. When the alt_timestamp() function returns the value 0, the timer has run down.
  • Maximum Time—The default Nios® V processor internal timer have 64 bits available to store the timer value. For Avalon timer peripherals, it can be 32 or 64 bits depending on the parametrization. Therefore, the maximum duration a timestamp timer can count is [(1/timer frequency) × 2bits_value] seconds. (bits_value = 32 or 64)