Freescale MCFxxxx On-Chip Wallclock Device Driver

Name

CYGPKG_DEVS_WALLCLOCK_MCFxxxx -- eCos Support for the Freescale MCFxxxx On-Chip Real-Time Clock

Description

Some members of the Freescale ColdFire range of processors come with an on-chip Real-Time Clock device which can act as an eCos wallclock. The device will not always be appropriate for an application's requirement. Typically it does not have its own low-current battery input so it will only operate when the whole processor is powered up. Hence either the entire system needs to be powered by a battery or have a battery backup. Otherwise the device will lose its settings when the power fails, requiring an application-level recovery mechanism, which means that there is no real advantage to using the RTC rather than a software emulation.

For those scenarios where the on-chip RTC does meet the application's requirements, this package CYGPKG_DEVS_WALLCLOCK_MCFxxxx provides an eCos device driver. The package will usually be loaded into the configuration automatically whenever selecting a target which contains a compatible device. By default it will provide the standard eCos wallclock device, although another implementation such as software emulation may be selected if desired. The only other configuration options related to this package allow users to change the compiler flags. If the application does not actually use the wallclock device, directly or indirectly, then the code should get removed automatically at link-time to ensure that the application does not suffer any unnecessary overheads.

Functionality

This wallclock device driver package implements the standard functionality required by the generic wallclock support CYGPKG_IO_WALLCLOCK. The functionality is not normally accessed directly. Instead it is used by the C library time package to implement standard calls such as time and gmtime. The eCos C library also provides a non-standard function cyg_libc_time_settime for changing the current wallclock setting. In addition RedBoot provides a date command which interacts with the wallclock device.

The wallclock driver does not provide any support for other functionality provided by the RTC device such as the alarm or stopwatch. It only manipulates the HOURMIN, SECONDS, DAYS, and CR registers. Applications can access the remaining registers as required without affecting the driver.

The wallclock package is initialized by a static constructor with a priority immediately after CYG_INIT_CLOCK. Applications should not call any wallclock-related functions before that constructor has run.

Porting

The driver requires only minimal porting. The HAL packages, typically the processor HAL, should supply the register definitions and the device base address HAL_MCFxxxx_RTC_BASE. In addition the platform HAL should define the crystal frequency using a #define of HAL_MCFxxxx_RTC_XTAL: legal values are 32768, 32000, and 38400. Finally the driver package CYGPKG_DEVS_WALLCLOCK_MCFxxxx should be included in the CDL target entry so that it gets loaded automatically whenever eCos is configured for that target.

2017-02-09
Documentation license for this page: eCosPro License