ece 447 fall 2009

13
ECE 447 Fall 2009 Lecture 13: TI MSP430 Watchdog Timer and Real-Time Clock

Upload: olga-sawyer

Post on 31-Dec-2015

25 views

Category:

Documents


1 download

DESCRIPTION

ECE 447 Fall 2009. Lecture 13: TI MSP430 Watchdog Timer and Real-Time Clock. ECE447: MSP430 Watchdog Timer Concept. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: ECE 447 Fall 2009

ECE 447 Fall 2009

Lecture 13: TI MSP430

Watchdog Timer

and Real-Time Clock

Page 2: ECE 447 Fall 2009

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.

Page 3: ECE 447 Fall 2009

ECE447: Use Cases for Watchdog Timer

• Out of Control Software:– Trapped in infinite loop– Code/Memory overwrite

• Peripheral Failure:– Polling a non responsive device

• SW controlled reset:– The WDT register can be used to force a

reset purposely

Page 4: ECE 447 Fall 2009

ECE 447: Enabling and Disabling the WDT

– The WDT is always active after a reset– Default 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.

Page 5: ECE 447 Fall 2009

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 register

• Any other value will cause an immediate reset.

Page 6: ECE 447 Fall 2009

ECE 447: WDT Control Register

Page 7: ECE 447 Fall 2009

ECE447: MSP430 Basic Timer1

• Basic Timer 1 provides two or three fucntions in the MSP430:– Clock for the LCD module– Periodic Interrupts– 1Hz clock signal to drive the Real-Time Clock

• The RTC only exists in newer MSP430xFxx family devices.

Page 8: ECE 447 Fall 2009

ECE447: MSP430 Basic Timer1

• BTCNT1 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.

Page 9: ECE 447 Fall 2009

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.

Page 10: ECE 447 Fall 2009

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-6– Day of month (RTCDAY)– Month (RTCMON)– Year (RTCYEARL), assuming BCD format– Century (RTCYEARH), assuming BCD format.

Page 11: ECE 447 Fall 2009

ECE447: MSP430 Real Timer Clock Data Registers

• The RTC is controlled by the RTCCTL• It 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.

Page 12: ECE 447 Fall 2009

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.

Page 13: ECE 447 Fall 2009

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.