我最近写一个读芯片数据通过串口发送给上位机,读到一个串口发送一个,上位机读取过程中发生An overrun error occurred during transfer. A character was not read from the hardware before the next character arrived.错误,
下面是我的设置,请问怎么设置可以避免上述错误?
void Init_Uart(void)
{
//Set UCSWRST
UCA1CTL1_bit.UCSWRST_A1 = 1;
UCA1CTL1 = 0x81;
UCA1BRW = 0x40; //7.3728M 115200baud
//Config port
P4SEL |= BIT4 + BIT5;
//Clear UCSWRST
UCA1CTL1_bit.UCSWRST_A1 = 0;
//Enable interrupt
UCA1IE_bit.UCRXIE_A1 = 1;
UCA1IE_bit.UCTXIE_A1 = 0;
return;
}
uchar Uart_TxByte(uchar hexchar)
{
while (!UCA1IFG_bit.UCTXIFG_A1);
UCA1TXBUF = hexchar;
return hexchar;
}