1 / 42

“Real-time Clock”

“Real-time Clock”. Texas Instruments University Programme Teaching Materials. Real-time Clock. Introduction. Portable devices such as mobile phones and PDAs display time and date Typically, time and date functions are controlled by a real-time clock, which runs off its own battery

yetty
Download Presentation

“Real-time Clock”

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. “Real-time Clock” Texas Instruments University Programme Teaching Materials

  2. Real-time Clock

  3. Introduction • Portable devices such as mobile phones and PDAs display time and date • Typically, time and date functions are controlled by a real-time clock, which runs off its own battery • The real-time clock can also be used to control other functions such as alarms, power management and event scheduling.

  4. Objectives • To configure the Real-time Clock (RTC) on the TMS320C5505 USB Stick • To introduce the Texas Instruments Chip Support Library (CSL) • To use the RTC to produce interrupts once every 1 second • To use the RTC to control Phase Locked Loop (PLL) to control the operating frequency and the power taken.

  5. TMS320C5505 Real-Time Clock

  6. RTC Clock Signals • The RTC Clock signal can be used to drive the System Clock (SYSCLK) • The output from the RTC is available on the RTC_CLKOUT pin of the TMS320C5505 USB Stick.

  7. RTC Frequency • The Real Time Clock runs at 32768 Hz • Slow enough to save battery life • Fast enough to give resolution of 1ms per ‘tick’ • A 32768 Hz crystal is a low cost item – it is widely used in digital watches.

  8. RTC Block Diagram

  9. RTC Time and Date Functionality • The real-time clock provides the following values for time and date operations: • Year • Month • Day • Hour • Minute • Second • Millisecond.

  10. RTC Alarm Functionality • The alarm functions like a standard alarm clock • When a certain time is reached, the alarm becomes active.

  11. RTC Interrupt Functionality

  12. RTC Registers

  13. RTC Update Register • When new values of time, date or alarm are written, the new values do not take effect until the TIMEUPT and/or ALARMUPDT bits are written • (Register RTCUPDATE 1901h).

  14. Interrupt Enable Register • In order to turn on RTC interrupts, the RTC interrupt must be enabled. (Register RTCINTEN 1900h).

  15. Interrupt Flag Register • Every time one of the RTC interrupt occurs, a flag needs to be cleared (Register RTCINTFL 1920h).

  16. RTC Power Management • Sets up wake up and controls the clock output on RTC_CLKOUT pin. (Register RTCPMGT 1930h).

  17. RTC Compensation • The 32768 Hz crystal frequency varies with temperature • To keep the time and date accurate, compensation can be applied. (Register RTCDRIFT 1928h).

  18. Using the Chip Support Library (CSL)

  19. Using the Chip Support Library (CSL) • Some good news! • Most the functions required to implement a RTC in software are already provided by the Chip Support Library (CSL) • This saves a great deal of work, particularly when implementing interrupts • It can be downloaded from www.ti.com

  20. CSL Example Code • The code for this application has been based on the CSL example code csl_rtc_example.c

  21. CSL RTC Data Structures • csl_rtc.h provides data structures for time and date.

  22. Interrupt Requests (IRQs) • The IRQ function prototypes are provided in csl_intc.h

  23. RTC to Control System Power

  24. LED Flash on Mobile Phone • A typical example of a RTC being used to control system power on a mobile phone might be: • When the phone is not in use, it is put to “sleep” • When 1 second in RTC has expired, the LED flashes and the processor wakes up • If there is an incoming call, the PLL is set to maximum speed • When the call is complete, the processor goes back to sleep.

  25. C Code Implementation

  26. Interrupt Service Routine (ISR) • The C code uses the special keyword “interrupt”.

  27. Bad Programming Practice • Interrupts should be kept short so they run fast • Do not use “printf” or any other slow function in an interrupt.

  28. Introduction to Laboratory

  29. Installing the Application • Copy the code given in Application 19 Real Time Clock to the workspace • Follow the steps previously given in Chapter 1 to set up the new project.

  30. Create New CCS Project

  31. Files Used in Project

  32. TMS320C5505 USB Stick Setup USB to PC Microphone Headphones

  33. How the Program Works • The program uses the RTC to control the PLL frequency and power dissipation • The RTC produces a periodic interrupt once every second • After 10 seconds the PLL changes from 40 MHz to 2 MHz (Low power) • After 60 seconds an alarm occurs. The the PLL changes to 100 MHz. (Full power. Maximum speed) • After 120 seconds a second alarm occurs which changes the PLL to 12 MHz (Lower power).

  34. Console for Setup

  35. Console for First Alarm

  36. Console for Second Alarm

  37. Monitoring RTC CLKOUT • The 32768 Hz RTCCLK is available on the RTC_CLKOUT pin of the TMS320C5505 USB Stick • It can be measured using a digital frequency meter.

  38. Experiments

  39. Setup New Time and Date • In real_time_clock.c, the date, time and alarm times are: • Date: 2010 May 25 • Time: 12 hours: 12 minutes: 12 seconds. • Alarm: 12 hours : 13 minutes : 12 seconds • Change these values to the actual date and time you are running your experiment.

  40. Time and Date Configuration

  41. Questions • If you change the time, date or alarm time, what extra register needs to be written to cause the values to change? • How accurate does the RTC clock have to be? Ideally the time and date should be accurate within 30 seconds per month or the customers will complain!

  42. References • TMS320VC5505 DSP System User’s Guide. SPRUFP0. • TMS320VC5505/5504 DSP Real-Time Clock (RTC) User’s Guide. SPRUFO7. • TMS320C55xx Chip Support Library API Reference Guide. SPRU433.

More Related