📄 fet140_tb03.c
字号:
//******************************************************************************
// MSP-FET430P140 Demo - Timer_B Toggle P1.0, overflow ISR, DCO SMCLK
//
// Description; Toggle P1.0 using using software and timer_B overflow ISR.
// In this example an ISR will trigger when TA overflows. Inside the TB
// overflow ISR P1.0 is toggled. Toggle rate is approximatlely 12hz.
// MCLK = SMCLK = TACLK = DCO ~ 800k.
// Proper use of TBIV interrupt vector generator demonstrated.
//
// MSP430F149
// ---------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P1.0|-->LED
//
// M. Buccini
// Texas Instruments, Inc
// January 2002
// Built with IAR Embedded Workbench Version: 1.25A
//******************************************************************************
#include <msp430x14x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
TBCTL = TBSSEL1 + TBCLR + TBIE; // SMCLK, clr. TBR, interrupt
P1DIR |= 0x01; // Set P1.0 to output direction
TBCTL |= MC1; // Start Timer_B in continous
_EINT(); // Enable interrupts
for (;;)
{
_BIS_SR(CPUOFF); // CPU off
_NOP(); // Required only for C-spy
}
}
// Timer_B7 Interrupt Vector (TBIV) handler
interrupt [TIMERB1_VECTOR] void Timer_B(void)
{
switch( TBIV )
{
case 2: break; // CCR1 not used
case 4: break; // CCR2 not used
case 14: P1OUT ^= 0x01; // overflow
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -