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.
Original post address:
http://bbs.21ic.com/icview-339370-1-1.html
Previous article:AD program of STC12C5410AD single chip microcomputer two digital tube display
Next article:SPI data memory expansion based on MSP430F12x2
Recommended ReadingLatest update time:2024-11-16 15:47
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications