📄 test44x_tb02.c
字号:
//******************************************************************************
// MSP430-TEST44X Demo - Timer_B Toggle P5.1, TBCCR0 upmode ISR, DCO SMCLK
//
// Description; toggle P5.1 using using software and TB_0 ISR. Timer_B is
// configured in upmode, thus the timer will overflow when TBR counts to TBCCR0.
// In this example, CCR0 is loaded with 20000.
// ACLK = n/a, MCLK = SMCLK = TACLK = DCO=1M
//
// MSP430F449
// ---------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P5.1|-->LED
//
// Lierda, Inc
// February 2006.03
// Built with IAR Embedded Workbench Version: 3.40A
// ID: MSP430-TEST44X
// DATA:2005-7-12
// REV: 2.0A
// 程序功能:该程序是用F449的内部TIMER_B CCR0的比较模式功能,来控制P5.1口驱动LED 500ms闪烁。
// 硬件连接:先连接P5.1口的短接器,然后连接键盘上方的短接器J2。
//
//******************************************************************************
#include <msp430x44x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
TBCTL = TBSSEL0 + TBCLR; // ACLK, clear TBR
TBCCTL0 = CCIE; // TBCCR0 interrupt enabled
TBCCR0 = 16384; // 500ms interrupt
P5DIR |= 0x02; // Set P5.1 to output direction
TBCTL |= MC0; // Start Timer_a in upmode
_EINT(); // Enable interrupts
for (;;)
{
_BIS_SR(CPUOFF); // CPU off
_NOP(); // Required only for C-spy
}
}
#pragma vector=TIMERB0_VECTOR
__interrupt void Timer_B (void)
{
P5OUT ^= 0x02; // Toggle P5.1 using exclusive-OR
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -