Take MSP430F2274 as an example. The assembly implementation uses IAR assembly, and the CCE assembly implementation can be slightly modified. 1. The watchdog has three working modes: stop mode, timer mode, and watchdog mode. 2. The clock sources that can be selected in the latter two modes are: SMCLK and ACLK. 3. When using the latter two modes, pay attention to whether the watchdog can work in the state of the microcontroller. For example, when the microcontroller is in LPM3, there is only ACLK clock, and in LPM4, there is no clock available. 4. How to use the watchdog mode: When the watchdog count overflows, the program is reset. Enable the watchdog in the program, clear the watchdog before the count overflows, or reset the watchdog to make it count again. If the program runs away, the watchdog may not be cleared or reset, which will overflow and reset the program. 5. In MSP430F2274, the maximum timer in watchdog mode is 1s. If you need to reset it with a longer time, you can use other counters and execute ((void (*)())RESET_VECTOR)(); after the count is full, or write an error value to the watchdog control register or execute an invalid command after the count is full: such as ((void (*)())0x170)(); 0x170 is an address of a peripheral module and cannot be a function address, so executing this sentence will reset the program. Stop mode: turn off watchdog C language implementation: WDTCTL = WDTPW + WDTHOLD Assembly language implementation: mov.w #WDTPW+WDTHOLD,&WDTCTL Timer mode: used as a timer, the watchdog interrupt function is executed when the counter is full and an interrupt is generated. C language implementation: In the main program: turn on the watchdog timer, such as: WDTCTL = WDT_MDLY_8; or WDTCTL = WDT_ADLY_250; etc. The watchdog interrupt function is: #pragma vector=WDT_VECTOR __interrupt void watchdog_timer(void) { //.................................. } Assembly language implementation: Turn on the watchdog timer, such as: mov.w #WDTPW+WDTTMSEL+WDTCNTCL+WDTIS0 ,&WDTCTL or mov.w #WDTPW+WDTTMSEL+WDTCNTCL+WDTSSEL+WDTIS0 ,&WDTCTL, etc. Watchdog interrupt vector in the interrupt vector table: ORG 0FFF4h ;watchdog interrupt address of msp430f2274 DW RESET ;The program starts with REST as the label Watchdog interrupt function: WDT_ISR ;.................... reti Watchdog mode: When the count overflows, the reset interrupt function is executed. C language implementation: Clear watchdog: WDTCTL = WDTPW+WDTCNCTL; Set watchdog: WDTCTL = WDT_MRST_0_5; Or WDTCTL = WDT_ARST_1000; etc. Assembly language implementation: Reset vector in the interrupt vector table: ORG 0FFFEh ;reset address of msp430f2274 DW RESET ;The program starts with REST as the label Clear watchdog:mov.w #WDTPW+WDTCNCTL,&WDTCTL Set watchdog: mov.w # WDTPW+WDTCNTCL+WDTIS1 ,&WDTCTL mov.w # WDTPW+WDTCNTCL+WDTSSEL,&WDTCTL;, etc. Extended reading: Watchdog application analysis