STM8的UART初始化完成后,不能发送数据,按例程中的再后面加上这个函数之后才能发送,想问一下大侠们,是不是在发送前还需要什么操作。。
char putchar (char c)
{
if (c == '\n')
{
/* put '\r' to hardware here */
/* Wait transmission is completed : otherwise the first data is not sent */
while (!(UART2_SR & 0x40));
UART2_DR = ('\r');
/* Wait transmission is completed */
while (!(UART2_SR & 0x40));
}
/* put c to hardware here */
/* Wait transmission is completed : otherwise the first data is not sent */
while (!(UART2_SR & 0x80));
UART2_DR = (c);
/* Wait transmission is completed */
while (!(UART2_SR & 0x80));
return (c);
} |