PSoC5LP Lab 09: I2C RTC Module

Objective

Overview

A Real-Time Clock (RTC) module in an embedded system is a dedicated hardware component that accurately tracks time, often across various power cycles. It provides precise timekeeping regarding seconds, minutes, hours, days, months, and years. RTCs are crucial for applications requiring accurate time management, such as data logging, scheduling tasks, alarms, and managing timestamps in file systems.

Key Features and Functions of RTC Modules

  1. Time and Date Tracking: An RTC maintains accurate time and date information. It can manage leap years, handle month-end adjustments, and keep track of hours, minutes, seconds, day of the week, and year.
  2. Battery Backup: RTCs typically operate with a low-power backup battery. This feature allows them to continue counting time even when the main power supply is off, ensuring uninterrupted time tracking.
  3. Low Power Consumption: Most RTC modules consume minimal power, making them ideal for battery-powered devices that require continuous timekeeping, such as wearable devices, portable equipment, and IoT nodes.
  4. Programmable Alarms and Interrupts: Many RTCs include alarm and interrupt features. Programmable alarms can trigger at specified times or intervals, which is useful for scheduling tasks in low-power modes or waking up the system from sleep.
  5. I2C or SPI Interface: RTCs commonly use I2C or SPI communication protocols to interface with microcontrollers, allowing simple, reliable integration into embedded systems.
  6. Automatic Calibration: Some advanced RTCs have self-calibration mechanisms to maintain high accuracy. This feature can correct for drift caused by temperature variations or oscillator aging.
  7. Applications: RTC modules are essential in applications where maintaining accurate time is critical, including:
    • Data logging (e.g., environmental monitoring)
    • Scheduled tasks and automation
    • Timestamping in file systems
    • Alarm systems and reminders
    • Low-power devices where periodic wake-ups are necessary

Popular RTC Modules

  • DS1307: A widely-used I2C-based RTC with battery backup and basic date/time tracking, suitable for simple applications.
  • DS3231: Known for high accuracy, this I2C RTC has an integrated temperature-compensated crystal oscillator (TCXO) and features alarms, making it ideal for precision applications.
  • PCF8563: This low-power RTC also uses I2C and is known for its power efficiency, making it popular in portable devices.

In summary, RTC modules in embedded systems enable precise and reliable timekeeping across power cycles, essential for any application requiring accurate time information or scheduled operations. Their low-power design and integration flexibility make them a core component in modern embedded and IoT systems.

Required Reading Material

Required Components

If you use the Cypress CY8CKIT-059 Kit, the onboard LED and button will be used in this lab.

The following components are required for this lab.

Button Small 64 DS3231 (or DS1307) RTC module x 1
Resistor 64 Character LCD Module x 1
LED Red 64 Red LED (or onboard LED) x 1

Circuit / Schematic

Procedure

Creating a New Project

  1. Launch PSoC Creator.
  2. Got to File ➤ Open Project ➤ Project/Workspace.
  3. Open the PSoC5LP workspace in the EE4450 folder.
  4. After PSoC Creator opens the workspace, right-click on Workspace 'PSoC5LP' in the Workspace Explorer and select Add ➤ New Project….
  5. Select the correct PSoC5LP device model number, use the "Empty schematic" template, and enter the project name 09_I2C_RTC.

Adding PSoC Creator Components

Open the "TopDesign.cysch" Schematic File, add the following components:

  • Add an I2C Master component:
    1. Similarly, go to the Communications ➤ I2C catalog.
    2. Drag and drop the PSoCCreator icon Catalog 3 I2C Master (UDB) onto the schematic.
  • Add a Character LCD component:
    1. Navigate to the Display catalog in the component selection panel.
    2. Drag and drop the PSoCCreator icon Catalog 4 Character LCD onto the schematic.

Configure the Components

  1. Config the Digital Output Pin (Pin_1):
    • Click on the Pin_1 component in the schematic.
    • Rename the component to Wire1 to represent its connection to the 1-wire sensor.
    • Uncheck the box for ☐ HW connection to disable the hardware connection. This step ensures that the pin will be controlled manually in the software.
    • Change the Drive Mode to the Open drain, drive low mode.
    Pin Wire1 s
  2. Config the Character LCD (LCD_Char_1):
    • Click on the LCD_Char_1 component in the schematic.
    • Rename the component to LCD for clarity and ease of identification.
    CharacterLCD LCD s

The new TopDesign.cysch file is shown below:

TopDesign

Pin Assignment

DevicePort.PinDirectionDrive Mode

Building the code and Programming

© 2024 Air Supply Information Center (Air Supply BBS)