Specifications

The following features and restrictions apply to the host based file system:
The host-based file system makes the Nios II C/C++ application project directory and its subdirecto‐
ries available to the HAL file system on the target hardware.
The target processor can access any file in the project directory. Be careful not to corrupt project
source files.
The host-based file system only operates while debugging a project. It cannot be used for run sessions.
Host file data travels between host and target serially through the Altera download cable, and therefore
file access time is relatively slow. Depending on your host and target system configurations, it can take
several milliseconds per call to the host. For higher performance, use buffered I/O function such as
fread() and fwrite(), and increase the buffer size for large files.
You configure the host-based file system using the Nios II BSP Editor. The host-based file system has one
setting: the mount point, which specifies the mount point within the HAL file system. For example, if you
name the mount point /mnt/host and the project directory on you host computer is /software/project1,
in a HAL-based program, the following code opens the file /software/project1/datafile.dat.:
fopen("/mnt/host/datafile.dat", "r");
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.
System Clock Driver
The HAL system clock driver provides a periodic heartbeat, causing the system clock to increment on
each beat. Software can use the system clock facilities to execute functions at specified times, and to obtain
timing information. You select a specific hardware timer peripheral as the system clock device by
manipulating BSP settings.
For more information about how to control BSP settings, refer to the “HAL BSP Settings” chapter.
The HAL provides implementations of the following standard UNIX functions: gettimeofday(),
settimeofday(), and times(). The times returned by these functions are based on the HAL system
clock.
The system clock measures time in clock ticks. For embedded engineers who deal with both hardware and
software, do not confuse the HAL system clock with the clock signal driving the Nios II processor
hardware. The period of a HAL system clock tick is generally much longer than the hardware system
clock. system.h defines the clock tick frequency.
6-14
Using Timer Devices
NII5V2
2015.05.14
Altera Corporation
Developing Programs Using the Hardware Abstraction Layer
Send Feedback