对呀,我的思路是这样的,但是设备第一次上电发送数据正确,以后的数据就不对了
put(){//将数据放入发送缓冲区
p_tx=TxBuffer;//指针
TxBuffer[TxBuf_WrIdx] = c;
TxBuf_WrIdx = (TxBuf_WrIdx+1) & (MAX_TXBUF_SIZE-1);
}
Handle(){//数据放入端点寄存器,发送,
UCR1 &= ~BM_TX1E;
UIR2 = BM_TXD1FR; n = 0;
if(TxBuf_RdIdx/8!=0)&&(TxBuf_RdIdx%8==0)
p_tx+=8;
dest = &UE1D0;
while((TxBuf_RdIdx != TxBuf_WrIdx) && n<8) {
*dest=*(p_tx+n);
TxBuf_RdIdx = (TxBuf_RdIdx - 1) & (MAX_TXBUF_SIZE-1);
dest++;
n++;
}
UCR1 = ((UCR1^BM_T1SEQ) & BM_T1SEQ) + BM_TX1E + n;
//指针移向下一组数据
} [此贴子已经被作者于2005-11-15 16:25:06编辑过]
[此贴子已经被作者于2005-11-16 10:46:25编辑过] |