17.3.1 Design Flow
The following steps are used to enable RTC in the application:
- Enable RTC by using the MSS configurator in the application, as shown in the following figure.
- Clicking RTC displays the RTC configuration window, as shown in the following
figure.
- Select the Clock Source that drives the RTC system (RTCCLK) as either External 32 KHz RTC crystal oscillator, or On-chip 1 MHz RC oscillator, or On-chip 25/50 MHz RC oscillator (50 MHz in 1.2V part). Irrespective of external main oscillator or RTC crystal oscillator selection, the auxiliary external oscillator is used as RTC clock source.
- Select the Wake-Up Interrupt. The RTC_WAKEUP_CR in the SYSREG block provides masking for the RTC_WAKEUP interrupt to the FPGA fabric, the Cortex-M3 processor, and the system controller. The interrupt to be enabled can be selected using this configurator.
- Select the RTC_MATCH. The RTC_MATCH status bit and output is asserted whenever the Alarm system is enabled and a match occurs. In Calendar mode, it is asserted for a 1 second period while the alarm condition is valid. The output is synchronous to the rising edge of the RTCCLK. The RTC_MATCH output signal can be exposed to drive the FPGA fabric. The RTC_MATCH signal is then available to be used in the design.
- The RTC signals in top-level instance are shown in the following figure.
- Generate the component by clicking Generate Component or by selecting . For more information on generation of the component, see the latest SmartDesign user guide on Libero SoC Documentation. The firmware driver folder and SoftConsole workspace is included in the project. Click the highlighted Configure firmware button as shown in the following figure to find the RTC drivers.
- Click Generate Bitstream under Program
Design to complete
*.fdb
file generation. - Double-click Export
Firmware under Handoff Design for
Firmware Development in the Libero SoC design flow window to
generate the SoftConsole Firmware Project. The SoftConsole folder contains the mss_rtc
firmware driver. The firmware driver, mss_rtc (
mss_rtc.c
andmss_rtc.h
) which provides a set of functions for controlling the RTC, can also be downloaded from the Microchip firmware catalog. The following table lists the APIs for RTC. For more information on the APIs, see the SmartFusion2_MSS_RTC_Driver_UG (shown in the preceding figure).Table 17-3. RTC APIs Category API Description and Usage Initialization MSS_RTC_init() Initializes RTC Setting and reading the RTC counter current value MSS_RTC_set_calendar_count() Sets new calendar values to RTC counter MSS_RTC_set_binary_count() Sets new binary values to RTC counter MSS_RTC_get_calendar_count() Returns calendar count MSS_RTC_get_binary_count() Returns binary counter value Setting the RTC match and mask values MSS_RTC_set_calendar_count_alarm() Sets the RTC to generate an alarm when the time and date passed as parameter MSS_RTC_set_binary_count_alarm() Sets the RTC to generate an alarm when the counter value passed as parameter RTC counter increment detection MSS_RTC_get_update_flag Indicates if the RTC counter incremented since the last call to MSS_RTC_clear_update_flag() MSS_RTC_clear_update_flag Clears the hardware flag set when the RTC counter increments Control of RTC MSS_RTC_start() Starts the RTC incrementing MSS_RTC_stop() Stops the RTC from incrementing MSS_RTC_reset_counter() Resets the calendar counters Interrupt control MSS_RTC_enable_irq() Enables the RTC wakeup interrupt MSS_RTC_disable_irq() Disables the RTC wake up interrupt MSS_RTC_clear_irq() Clears pending RTC wakeup interrupt - For more information on RTC usage, sample projects that are available can be generated, as shown in the following figure.