Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

7.9. Using Timer Devices

Timer devices are hardware peripherals that count clock ticks and can generate periodic interrupt requests. You can use a timer device to provide a number of time-related facilities, such as the HAL system clock, alarms, the time-of-day, and time measurement. To use the timer facilities, the Nios® II processor system must include a timer peripheral in hardware.

The HAL API provides two types of timer device drivers:

  • System clock driver—Supports alarms, such as you would use in a scheduler.
  • Timestamp driver—Supports high-resolution time measurement.

An individual timer peripheral can behave as either a system clock or a timestamp, but not both.

For more information about where the HAL-specific API functions for accessing timer devices are defined, refer to the sys/alt_alarm.h and sys/alt_timestamp.h files.