我看了一下程序好像有个函数不太一样,
其中一个是这样:
// 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
while ( TACCTL0 & CCIE ); // Wait for TX completion
}
另外一个是这样:
void Transmit()
{
BitCnt = 0xA; // 装载位计数器, 8data + ST/SP
while (CCR0 != TAR) // 防止异步捕获
CCR0 = TAR; // 当前TA计数器的状态
CCR0 += Bitime; // 一些时间直到第一位
TXByte |= 0x100; // 新增标记停止位TXByte
TXByte = TXByte << 1; // 加空间的起始位
CCTL0 = CCIS0 + OUTMOD0 + CCIE; // TXD = mark = idle
while ( CCTL0 & CCIE ); // 等待TX完成
}
不是太明白二者的区别,希望大哥大姐给分析一下!
|