网站大量收购独家精品文档,联系QQ:2885784924

串口通信 主机程序与从机程序(Serial communication host program and slave program).doc

串口通信 主机程序与从机程序(Serial communication host program and slave program).doc

  1. 1、本文档共11页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 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

您可能关注的文档

文档评论(0)

f8r9t5c + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8000054077000003

1亿VIP精品文档

相关文档