为什么这个程序单步执行时串口接收进不了中断。
#include <msp430f5529.h>
unsigned char RXBuffer=0x00;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P4SEL |=BIT5;
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1BR0 = 6; // 1MHz 9600 (see User's Guide)
UCA1BR1 = 0; // 1MHz 9600
UCA1MCTL |= UCBRS_0 + UCBRF_13+UCOS16; // Modulation UCBRSx=0, UCBRFx=2
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE |= UCRXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(GIE); // interrupts enabled
__no_operation(); // For debugger
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
switch(__even_in_range(UCA1IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
RXBuffer= UCA1RXBUF; // TX -> RXed character
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}
程序相关的问题请发到MCU板块去。