您的当前位置:首页正文

UART发送的测试程序

2020-02-28 来源:客趣旅游网


/**UART发送的测试程序

**使用查询方式发送一串字符串到UART/

#include “io8515.h”

/*声明一个存放在程序空间的字符串数组a[]*/

Const char a[]= “This is a test message!”;

Unsigned char pos=0

Void sendchar(unsigned char c)

{

While(!GET_BIT(USR,TXC));

SET_BIT(USR,TXC);

}

Int main(void)

{

SET_BIT(UCR,TXEN); / 允许UART发送数据 /

USRR=25; / 初始化波特率产生器 /

CLI(); / 关闭全局中断 /

While(pos<23)

{

Send(a[pos]); Pos ++;

}

For(;;)

;

}

/ 写一个字节到UART /

因篇幅问题不能全部显示,请点此查看更多更全内容