我看了一下程序好像有个函数不太一样,
其中一个是这样:
// Function Transmits Character from TXByte
void Transmit()
{
BitCnt = 0xA; // Load Bit counter, 8data + ST/SP
/* Simulate a timer capture event to obtain the value of TAR into the TACCR0 register */
TACCTL0 = CM_1 + CCIS_2 + SCS + CAP + OUTMOD0; //capture on rising edge, initially set to GND as input // clear CCIFG flag
TACCTL0 |= CCIS_3; //change input to Vcc, effectively rising the edge, triggering the capture action
while (!(TACCTL0 & CCIFG)); //allowing for the capturing//updating TACCR0.
TACCR0 += Bitime ; // Some time till first bit
TXByte |= 0x100; // Add mark stop bit to TXByte
TXByte = TXByte << 1; // Add space start bit
TACCTL0 = CCIS0 + OUTMOD0 + CCIE; // TXD = mark = idle