Microchip
直播中

李岩

7年用户 210经验值
私信 关注
[问答]

如何删除pic18f中uart中的多余字符

我有PIC18F2520,我正在做简单的UART程序。我使用了遗留库。以下是演示代码:数据显示在终端上,但是在Hello之前还有一个空字符。我附上了一个终端数据的图片。请看一下。

以上来自于百度翻译


      以下为原文

    I have PIC18F2520 and I am doing simple UART program. I have used the legacy libraries.
Following is the demo code:

OpenUSART( USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH,51 );
while(1)
{
   putrsUSART("Hellon");
   DelayMs(500);
}

Data is showing on the terminal but there is one extra NULL char before Hello. I have attached an image of the terminal data. Please have a look at it.

   Attached Image(s)

回帖(3)

王焕树

2019-7-24 15:17:46
PLIB函数PutrSuxAtter()在字符串上发送终止null。只需滚动自己的函数就不发送它。

以上来自于百度翻译


      以下为原文

    The plib function putrsUSART() sends the terminating NULL on the string.
Just roll your own function to not send it.
 
举报

郭武莱

2019-7-24 15:24:47
你能给出演示代码吗?

以上来自于百度翻译


      以下为原文

    @qhb can you give a demo code
举报

宋艳艳

2019-7-24 15:46:36
首先,你应该自己动手写一遍,如果你有困难,可以找我们寻求帮助。这不会太难,简单的循环,检查字符是否为空,导致循环退出,还有一两件小事应该变得明显。从练习中复制比粘贴别人的代码。

以上来自于百度翻译


      以下为原文

   


You should have a go at writing it yourself to begin with, and if you have trouble get back to us for help.

It really wont be that hard, a simple loop, a check if the character is NULL which causes the loop to exit, and one or two more little things which should become apparent.
 
You will learn far more from that exercise than copy/pasting someone elses code.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分