NetBurner 3.5.6
PDF Version
NTP & Real-Time Clock

NTP-SYSTEM-RTC DEMO APPLICATION

Note
HARDWARE SETUP: Tested with MOD54415 on a MOD-DEV-70 hardware rev 1.93.

NTP-System-RTC Demo Application

A NetBurner embedded system application that demonstrates synchronization between Network Time Protocol (NTP) servers, system time, and Real-Time Clock (RTC) hardware components.

Overview

This application provides a comprehensive example of time management in embedded systems, showcasing the interaction between network-based time synchronization, system time management, and hardware RTC persistence. The demo is particularly useful for applications requiring accurate timekeeping that persists across power cycles.

Hardware Requirements

  • Primary Platform: MOD54415 module
  • Development Board: MOD-DEV-70 (hardware revision 1.93 or compatible)
  • RTC Component: One of the following supported RTC chips:
    • Intersil X1226
    • NXP PCF8563

The RTC component must be present either on the module itself or on the development board to utilize the RTC-related features.

Features

Core Functionality

  1. NTP Time Synchronization
    • Retrieves current UTC time from NTP server pool (pool.ntp.org)
    • Updates system time with network-sourced accurate time
    • Requires DNS resolution capability
  2. System-RTC Synchronization
    • Saves current system time to hardware RTC
    • Restores system time from RTC after power cycles
    • Maintains time accuracy during power interruptions
  3. Time Zone Support
    • Configurable local time zone settings
    • Pacific Time Zone (PST/PDT) preconfigured as example
    • Automatic daylight saving time transitions
    • Customizable via tzsetchar() function
  4. Time Persistence
    • RTC continues running on super-capacitor power during outages
    • System time restoration from RTC after reset/power loss
    • Software reset capability for testing RTC persistence
  5. Time Display and Verification
    • Real-time display of UTC and local times
    • RTC time information display
    • Synchronization status verification
    • Time zone configuration display

Application Menu

The application provides an interactive menu with the following options:

  • [1] Sync system time with NTP server (requires DNS)
  • [2] Synchronize RTC from current system time
  • [3] Synchronize system time from RTC
  • [4] Verify synchronization between system and RTC
  • [5] Display current system and RTC times
  • [6] Re-display menu options
  • [0] Software reset device (tests RTC persistence)

Technical Details

Time Storage Format

  • System Time: Managed by NetBurner OS, stored as time_t
  • RTC Time: Hardware-based, stores UTC time (recommended)
  • Local Time: Calculated from UTC using configured time zone

Synchronization Logic

The application implements bidirectional synchronization:

  • NTP > System: Network time updates local system clock
  • System > RTC: Persistent storage of accurate time
  • RTC > System: Time recovery after power cycles

Error Handling

  • Network connectivity verification for NTP synchronization
  • RTC hardware communication error detection
  • DNS resolution failure handling
  • Synchronization status reporting

Network Requirements

For NTP Functionality

  • Active network connection (Ethernet recommended)
  • DNS server configuration (required for pool.ntp.org resolution)
  • Outbound NTP traffic (port 123) capability

Static IP Considerations

When using static IP configuration, manually configure DNS server addresses to enable NTP server name resolution.

Time Zone Configuration

The application uses Pacific Time as a demonstration. To configure for different time zones:

// Example for Eastern Time
char tzInfo[] = "EST5EDT4,M3.2.0/02:00:00,M11.1.0/02:00:00";
tzsetchar(tzInfo);
void tzsetchar(const char *tzenv)
Set the system local time.

Refer to NetBurner Runtime Libraries documentation (Chapter 14 - NBTime Library) for detailed time zone configuration syntax.

Build and Deployment

Prerequisites

  • NetBurner development environment
  • Compatible NetBurner runtime libraries
  • Hardware with supported RTC component

Key Libraries

  • nbtime.h - NetBurner time management
  • rtc.h - Real-time clock interface
  • hal.h - Hardware abstraction layer
  • init.h - System initialization

Usage Scenarios

  1. Initial Setup: Use option [1] to sync with NTP, then option [2] to save to RTC
  2. Power Recovery: After power loss, use option [3] to restore system time from RTC
  3. Verification: Use option [4] to confirm system and RTC synchronization
  4. Monitoring: Use option [5] to display current time status
  5. Testing: Use option [0] to test RTC persistence across resets

Limitations

  • Requires active network connection for NTP synchronization
  • DNS resolution needed for NTP server access
  • RTC persistence depends on super-capacitor charge level
  • Synchronization accuracy limited to minute-level precision

Applications

This demo serves as a foundation for:

  • Data logging systems requiring accurate timestamps
  • Scheduled task execution in embedded systems
  • Time-sensitive industrial automation
  • Network-connected IoT devices with offline operation requirements
  • Real-time data acquisition systems