
3 Porting a BSP to Custom Hardware
3.3 Finalizing Your BSP
109
3
match value is advanced. To implement the one-shot timer, a match count value is
computed for N ticks. When the system wakes up, the number of ticks slept is
computed using the timer count register. It should be noted that this time
computation requires a divide operation. Depending on your core hardware
design, this operation may be time consuming, but it cannot be avoided. Keeping
the one-shot timer and system timer locked is straightforward in this example
because the same timer is used for both functions. Care is taken to ensure that the
wake up time is in the future.
The ARM Amba timer provides three hardware timers. Each uses a preset value
that is reloaded when the timer reaches zero. Using different clock sources for the
tick and one-shot timers requires a time consuming conversion to compute the
fraction of a tick remaining in the system timer. Timers 1 and 2 use the same clock
source, so they are used for the system and one-shot timers. Because they use the
same source, they can be kept phase-locked with relative ease. The Amba timers
have a limited dynamic range. Changing the prescaler allows you to extend the
timer interrupt to approximately 700 ms. As noted earlier, changing the scalar
values reduces the accuracy of the sleep clock. However, this does not reduce
system clock accuracy because the system tick timer is allowed to run during sleep
periods. When the system wakes up, time is synchronized.
Non-Volatile Memory
The generic NVRAM and flash drivers reside in the target/src/drv/mem directory.
The template file templateNvRam.c is included in this directory. This file provides
the template driver to be used as the basis of non-volatile memory drivers,
including flash. However, do not use this template for the optional True Flash File
System (TrueFFS) product. For information on TrueFFS drivers, refer to the
documentation accompanying special memory technology drivers (MTDs) for
flash devices or see the VxWorks Device Driver Developer’s Guide: Flash (TrueFFS)
Drivers.
All BSPs are required to have some type of non-volatile memory interface, even if
non-volatile memory is not available. The two required routines are
sysNvRamGet( ) and sysNvRamSet( ). Both of these routines require an offset
parameter. Internally, these routines use the offset parameter as follows:
offset += NV_BOOT_OFFSET; /* boot line begins at <offset> = 0 */
if ((offset < 0) || (strLen < 0) || ((offset + strLen) >
NV_RAM_SIZE))
return (ERROR);
Comentários a estes Manuais