This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[MSP-EXP430F5529LP] 为什么串口只能在中断中才能发送?请大佬指教

开发板是电赛赠送的:EXP430F5529LP
环境是:CCS

在官方例程中,关于串口的发送和接收是如下这样子写的:
  1. // Echo back RXed character, confirm TX buffer is ready first
  2. #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
  3. #pragma vector=USCI_A0_VECTOR
  4. __interrupt void USCI_A0_ISR(void)
  5. #elif defined(__GNUC__)
  6. void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
  7. #else
  8. #error Compiler not supported!
  9. #endif
  10. {
  11.   switch(__even_in_range(UCA0IV,4))
  12.   {
  13.   case 0:break;                             // Vector 0 - no interrupt
  14.   case 2:                                   // Vector 2 - RXIFG
  15.     while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
  16.     UCA0TXBUF = UCA0RXBUF;                  // TX -> RXed character
  17.     break;
  18.   case 4:break;                             // Vector 4 - TXIFG
  19.   default: break;
  20.   }
  21. }
复制代码


也就是说在串口中断中收到之后就发送出去,但是怎么才能在主函数中进行发送呢?
我封装了一个如下的函数:
  1. void send_byte(unsigned char x)
  2. {
  3.     while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
  4.          UCA0TXBUF = x;
  5. }
  6. void send_str(unsigned char *s)
  7. {
  8.     while(*s != '\0')
  9.         send_byte(*s++);
  10. }
复制代码


但是并不能在主函数中进行串口的发送。请大佬指教