1230 views|0 replies

3836

Posts

19

Resources
The OP
 

MSP430 MCU watchdog practical method [Copy link]

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

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list