- 1、本文档共11页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
串口通信 主机程序与从机程序(Serial communication host program and slave program)
串口通信 主机程序与从机程序(Serial communication host program and slave program)
Serial communication
Host program:
#include config.h
#define UART_BPS 115200 / / define baud rate
Uint8 const SEND_STRING[] = Hello World!;
/****************************************************************************
* Name: DelayNS ()
* function: long software delay
* inlet parameter: dly delay parameter, the greater the value, the longer the delay
* export parameters: None
****************************************************************************/
Void DelayNS (uint32 dly)
{uint32 i;
For ((dly0; dly--)
{
For (i=0; i5000; i++);
}
}
/****************************************************************************
* Name: UART0_Ini ()
* function: initializes serial port 0. Set to 8 bit data bits, 1 bit stop bits, no parity, and a baud rate of 115200
* entrance parameter: None
* export parameters: None
****************************************************************************/
Void UART0_Init (void)
{uint16 Fdiv;
U0LCR = 0x83; / / DLAB = 1, baud rate can be set
Fdiv = (Fpclk / 16 / UART_BPS); / / set the baud rate
U0DLM = Fdiv / 256;
U0DLL = Fdiv% 256;
U0LCR = 0x03;
}
/****************************************************************************
* Name: UART0_SendByte ()
* function: send byte data to the serial port, and wait for the completion of the transmission.
* entry parameter: data data to be sent
* export parameters: None
****************************************************************************/
Void UART0_SendByte (uint8 data)
{
U0THR = data; / / send data
While ((U0LSR0x40) ==0); / / wait for data sent
}
/****************************************************************************
* Name: UART0_SendStr ()
* function: Send a string to the serial port
* portal parameter: the pointer to the string to be sent by SRT
* export parameters: None
****************************************************************************/
Void UART0_SendStr (uint8, const, *str)
{
While (1)
{
If (*str = =\0) break
您可能关注的文档
- 《苦痛者的天籁》阅读答案(The voice of the suffering man, read the answer).doc
- 《英雄传说5海之槛歌》全攻略(Legend of Heroes 5 the song of the sea).doc
- 《英雄传说空之轨迹3rd》主线任务攻略(Heroes Legend empty tracks 3rd main line quests).doc
- 《荣誉勋章诺曼底大空降》全攻略过关密码_百度知道(Medal of honor airborne Normandy Raiders pass password _ Baidu know).doc
- 《经济学概论》教学大纲(Outline of Economics).doc
- 《西方经济学》教学大纲(The syllabus of Western Economics).doc
- 《踏歌》的舞蹈形态和意象体会(Experience of the image and form of dance dance).doc
- 《货币金融学》课程教学大纲(Syllabus of the course of money and Finance).doc
- 《魔兽世界》导师的赠礼(World of Warcraft tutor gift).doc
- 《运动生物化学》理论教学大纲(Theoretical syllabus of exercise biochemistry).doc
- 2025至2030年中国男式高尔夫球裤数据监测研究报告.docx
- 2025至2030年中国疏水扩容器数据监测研究报告.docx
- 2025至2030年中国皮带笔皮便笺数据监测研究报告.docx
- 2025至2030年中国盘管式真空浓缩锅数据监测研究报告.docx
- 2025至2030年中国皮鞋塑跟数据监测研究报告.docx
- 2025至2030年中国盐焗青豆数据监测研究报告.docx
- 2025至2030年中国益坤宁片数据监测研究报告.docx
- 2025至2030年中国盒中袋葡萄酒数据监测研究报告.docx
- 2025至2030年中国盐度自动折射仪数据监测研究报告.docx
- 2025至2030年中国盐酸二甲双胍溶胶囊数据监测研究报告.docx
文档评论(0)