本帖最后由 昊430 于 2017-10-21 17:32 编辑
- #include <io430g2553.h>
- #include <in430.h>
- //#include "BoardConfig.h"
- void main(void)
- {
- unsigned int i;
- //BoardConfig(0xb8);
- BCSCTL1 |= DIVA_2; // ACLK/4
- WDTCTL = WDT_ADLY_1000; // WDT 1s/4 interval timer
- IE1 |= WDTIE; // Enable WDT interrupt
- P1DIR |= BIT6;
- P1OUT |= BIT6;
- for (i = 180; i>0; i--);
- P1OUT &= ~BIT6;
-
- while(1)
- {
- unsigned int i;
- _BIS_SR(LPM3_bits + GIE); // Enter LPM3
- P1OUT |= BIT6; // Set P3.5 LED on
- for (i = 180; i>0; i--); // Delay
- P1OUT &= ~BIT6; // Clear P3.5 LED off
- }
- }
- #pragma vector=WDT_VECTOR
- __interrupt void watchdog_timer (void)
- {
- _BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
- }
复制代码
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
但是仿真模式下我也是全速运行的,没有让它单步运行
//******************************************************************************
// MSP430G2xx3 Demo - WDT, Toggle P1.0, Interval Overflow ISR, 32kHz ACLK
//
// Description: Toggle P1.0 using software timed by WDT ISR. Toggle rate is
// exactly 250ms based on 32kHz ACLK WDT clock source. In this example the
// WDT is configured to divide 32768 watch-crystal(2^15) by 2^13 with an ISR
// triggered @ 4Hz.
// ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = default DCO
// //* External watch crystal installed on XIN XOUT is required for ACLK *//
//
// MSP430G2xx3
// -----------------
// /|| XIN|-
// | | | 32kHz
// --|RST XOUT|-
// | |
// | P1.0|-->LED
//
// D. Dang
// Texas Instruments Inc.
// December 2010
// Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
//******************************************************************************
#include <msp430.h>
int main(void)
{
WDTCTL = WDT_ADLY_250; // WDT 250ms, ACLK, interval timer
IE1 |= WDTIE; // Enable WDT interrupt
P1DIR |= 0x01; // Set P1.0 to output direction
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/interrupt
}
// Watchdog Timer interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(WDT_VECTOR))) watchdog_timer (void)
#else
#error Compiler not supported!
#endif
{
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
}
两种状态下的闪烁情况不一样,下载程序后运行是8秒灭,8秒亮;
仿真状态下差不多是0.5秒灭,0.5秒亮;
仿真状态下和正常运行时的时钟不一样吗?
一周热门 更多>