📄 msp430x54x_ta3_04.c
字号:
//******************************************************************************
// msp430FG5438 Demo - Timer_A3, Toggle P1.0, Overflow ISR, 32kHz ACLK
//
// Description: Toggle P1.0 using software and the Timer_A overflow ISR.
// In this example an ISR triggers when TA overflows. Inside the ISR P1.0
// is toggled. Toggle rate is exactly 0.5Hz. Proper use of the TAIV interrupt
// vector generator is demonstrated.
// ACLK = TACLK = 32768Hz, MCLK = SMCLK = default DCO ~1.045MHz
//
// msp430FG5438
// ---------------
// /|\| |
// | | |
// --|RST |
// | |
// | P1.0|-->LED
//
// M Smertneck
// Texas Instruments Inc.
// April 2008
// Built with CCEv3.2 IAR Embedded Workbench Version: 3.42A
//******************************************************************************
#include <msp430x54x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x01; // P1.0 output
TA1CTL = TASSEL_1 + MC_2 + TAIE; // ACLK, contmode, interrupt
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt
}
// Timer_A3 Interrupt Vector (TAIV) handler
#pragma vector=TIMER1_A1_VECTOR
__interrupt void Timer_A(void)
{
switch( TA1IV )
{
case 2: break; // CCR1 not used
case 4: break; // CCR2 not used
case 6: break; // CCR3 not used
case 8: break; // CCR4 not used
case 10: break; // CCR5 not used
case 12: break; // Reserved not used
case 14: P1OUT ^= 0x01; // overflow
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -