1244 views|0 replies

2015

Posts

0

Resources
The OP
 

How to use MSP430 watchdog [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 under the state of the MCU. For example, when the MCU 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 restart the count. If the program runs away, the watchdog may not be cleared or reset, and it will overflow, causing the program to reset.

5. In MSP430F2274, the maximum timing in watchdog mode is 1s. If a longer reset time is required, 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: Disable 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:

Enable 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 ;msp430f2274 watchdog interrupt address

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 ;msp430f2274 reset address

DW

RESET; The program starts with REST as the label

Clear watchdog: mov.w #WDTPW+WDTCNCTL,&WDTCTL

Set up the watchdog:

mov.w

# WDTPW+WDTCNTCL+WDTIS1 ,&WDTCTL

mov.w

# WDTPW+WDTCNTCL+WDTSSEL,&WDTCTL;etc.

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

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

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