Presentation on theme: "Lecture 13: TI MSP430 Watchdog Timer and Real-Time Clock"— Presentation transcript:
1 Lecture 13: TI MSP430 Watchdog Timer and Real-Time Clock ECE 447 Fall 2009Lecture 13: TI MSP430Watchdog Timerand Real-Time Clock
2 ECE447: MSP430 Watchdog Timer Concept A watchdog timer (or computer operating properly timer) is a hardware timing device that triggers a system reset if the main program, due to some fault condition, such as a hang, neglects to regularly service the watchdog.
3 ECE447: Use Cases for Watchdog Timer Out of Control Software:Trapped in infinite loopCode/Memory overwritePeripheral Failure:Polling a non responsive deviceSW controlled reset:The WDT register can be used to force a reset purposely
4 ECE 447: Enabling and Disabling the WDT The WDT is always active after a resetDefault settings allow the software about 32ms to clear, stop, or reconfigure the WDT at startup.Up until now we have always stopped the WDT by setting the WDT-HOLD bit.
5 ECE447: Petting the Watchdog Petting is performed by writing to the WDT-CNTCL bit.All writes to the WDT register are protected by a 8 bit password.0x5A must be the upper byte value of any write to the WDTCTL registerAny other value will cause an immediate reset.
7 Basic Timer 1 provides two or three fucntions in the MSP430: ECE447: MSP430 Basic Timer1Basic Timer 1 provides two or three fucntions in the MSP430:Clock for the LCD modulePeriodic Interrupts1Hz clock signal to drive the Real-Time ClockThe RTC only exists in newer MSP430xFxx family devices.
8 ECE447: MSP430 Basic Timer1BTCNT1 and BTCNT2 count based on control bits in BTFRQx and BTIPx.BTCNT2 causes the BTIFG flasg to be set at each rollover, with a rame from 16ms to 2s.
9 ECE447: MSP430 Real Timer Clock Concept A Real-Time Clock (RTC) is a hardware device that counts time based on seconds, minutes, hours, days, months, and year.Unlike most clocks in a microcontroller that do not convey useful data directly, the RTC is directly human understandable.
10 ECE447: MSP430 Real Timer Clock Concept The current time and date are held in a set of registers that contain the following bytes:Second (RTCSEC)Minute (RTCMIN)Hour (RTCHOUR), which runs from 0-23 (24-hour format)Day of week (RTCDOW), which runs from 0-6Day of month (RTCDAY)Month (RTCMON)Year (RTCYEARL), assuming BCD formatCentury (RTCYEARH), assuming BCD format.
11 ECE447: MSP430 Real Timer Clock Data Registers The RTC is controlled by the RTCCTLIt is initially disabled at reset (RTCHOLD is set)It can store its data registers in BCD or unsigned binary numbers (RTCBDC)Care should be taken in reading the RTC, see Davies p286.
12 ECE447: MSP430 Real Timer Clock Data Registers The Real-Time Clock has an interrupt flag RTCFG and corresponding enable bit RTCIE in RTCCTL.The flag is set every minute, every hour, daily at midnight, or daily at noon depending on the RTCTEVx bits.There is no alarm interrupt function, this must be implemented in software if desired.
13 ECE447: MSP430 Class Exercise Write a C program that sets up the RTC and sets the date to today, 18:00:00, and starts the time displaying on the Hitachi LCD module attached to P1 (4-bit mode) The time will be displayed in 24hr format with hours, minutes, and seconds. The output should be updated any time that the corresponding values are updated in the RTC registers.