fet440_tb_02.c
来自「MSP430F43x,MSP430F44x系列单片机调试程序下载」· C语言 代码 · 共 43 行
C
43 行
//******************************************************************************
// MSP-FET430P440 Demo - Timer_B, Toggle P5.1, CCR0 Up Mode ISR, DCO SMCLK
//
// Description: Toggle P5.1 using software and TB_0 ISR. Timer_B is
// configured for up mode, thus the timer overflows when TBR counts to
// CCR0. In this example, CCR0 is loaded with 20000.
// ACLK = n/a, MCLK = SMCLK = TBCLK = default DCO
//
// MSP430F449
// ---------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P5.1|-->LED
//
// M. Buccini / A. Dannenberg
// Texas Instruments Inc.
// May 2005
// Built with Code Composer Essentials Version: 1.0
//******************************************************************************
#include <msp430x44x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P5DIR |= 0x02; // Set P5.1 to output direction
TBCCTL0 = CCIE; // TBCCR0 interrupt enabled
TBCCR0 = 20000;
TBCTL = TBSSEL_2 + MC_1; // SMCLK, up mode
_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}
// Timer B0 interrupt service routine
__interrupt void Timer_B (void);
TIMERB0_ISR(Timer_B)
__interrupt void Timer_B (void)
{
P5OUT ^= 0x02; // Toggle P5.1 using exclusive-OR
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?