更改官方(iar)code
但終端機無法收到f5529傳的值
想請教各位大大問題點在哪裡??
#include <msp430f5529.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3SEL = BIT3+BIT4; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR0 = 0x03; // 32kHz/9600=3.41 (see User's Guide)
UCA0BR1 = 0x00; //
UCA0MCTL = UCBRS_3+UCBRF_0; // Modulation UCBRSx=3, UCBRFx=0
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
// over sampling
while(1)
{
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 67; // TX -> RXed character
__delay_cycles(500000);
}
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
__no_operation(); // For debugger
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,4))
{
case 0: // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 66; // TX -> RXed character
break;
case 4: // Vector 4 - TXIFG
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 68; // TX -> RXed character
break;
default: break;
}
}
此帖出自
小平头技术问答
他的switch语句中,这个函数的计算结果是__even_in_range(UCA0IV,4),是0,2,4,这些数字吗
一周热门 更多>