The MSP430 series has rich timer resources: watchdog timer (WDT), basic timer (Basic Timer1), timer A (Timer_A) and timer B (Timer_B), real-time clock (RTC), etc.
Their basic functions are as follows:
a) Watchdog timer: basic timing, performs a controlled system restart when a program error occurs;
b) Basic timer: basic timing, supporting software and various peripheral modules to work under low frequency and low power consumption conditions;
c) Real-time clock (RTC): basic timing and calendar functions;
d) Timer A: basic timing, supports multiple timing controls, multiple capture/compare functions and multiple output waveforms (PWM) at the same time, and can support serial communication in hardware;
e) Timer B: basic timing, the functions are basically the same as Timer A, but it is more flexible and powerful than Timer A;
Watchdog Timer (WDT):
a)WDT register
Counting unit WDTCNT: 16-bit up-counting, the fixed-period pulse signal generated by the clock circuit selected by the MSP430 adds to the counter from the beginning until the count overflows. WDTCNT cannot be accessed directly by software, but must be controlled by the control register WDTCTL of the watchdog timer.
b) Control register WDTCL
WDTCTL consists of two parts: the upper 8 bits are used as passwords, and the lower 8 bits are control commands for WDT operations. To write control commands for WDT operations, you must first write the correct password. The password is 5AH, and an error will cause the system to reset. Reading WDTCTL does not require a password and can be read directly. The low byte of the read data is the value of WDTCTL, and the high byte is always 69H.
1. WDTHOLD: stop watchdog, 1 stop
2. WDTNMIES: Watchdog NMI (non-maskable interrupt) trigger edge selection. When WDTNMI is 1, modifying this bit generates an interrupt, and when it is 0, it does not generate an interrupt. If this bit is 0, NMI is triggered on the rising edge, and if it is 1, NMI is triggered on the falling edge.
3. WDTNMI: Watchdog NMI selection, select the function of the RST/NMI pin. When it is 0, it is the reset function, and when it is 1, it is the NMI function.
4. WDTTMSEL: Watchdog working mode selection, 0 is watchdog mode, 1 is timer mode.
5. WDTCNTCL: When it is 1, the watchdog counter is cleared.
6. WDTSSEL: Watchdog clock source selection, select SMCLK when it is 0, and select ACLK when it is 1.
7. WDTISx: Timing output of the watchdog timer, 00 counts 32768, 01 counts 8192, 10 counts 512, 11 counts 64.
c) Interrupt enable register IE1:
1. NMIE: interrupt enable when 1
2. WDTIE: Watchdog timer enable. This bit is set to 1 when working in timer mode. It is not necessary to set it to 1 when working in watchdog mode because other interrupts may occupy this bit.
d) Interrupt flag register IFG1:
1. NMIFG: 1 indicates an interrupt occurs, 0 indicates no interrupt occurs. This bit must be cleared by software.
2. WDTIFG: Watchdog timer interrupt bit. In watchdog mode, it needs to be cleared by software. In timer mode, it will be automatically cleared when processing an interrupt. There is an interrupt when it is 1, and there is no interrupt when it is 0.
|