UCA0IE |= UCRXIE和UCA1IE |= UCTXIE中断要一起开开吗?这两个好像都是进入USCI_A0_VECTOR中断。
这是我写的uart发送与接收子函数,但不知道为什么一直不能用
//发送字符
void USCIA0_sendchar(unsigned char c)
{
UCA0TXBUF=c;
while(!(UCA0IFG & UCTXIFG));
UCA0IFG &=~UCRXIFG;
}
//接收字符
void USCIA0_receivechar(void)
{
unsigned char data = 0;
while(!(UCA0IFG & UCRXIFG));
UCA0IFG &=~UCRXIFG;
UCA0TXBUF = UCA0TXBUF;
return UCA0TXBUF;
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
USCIA0_receivechar();
USCIA0_sendchar('a');
} |