avr单片机实现的485通讯从机接收程序(带帧校验)单片机(AVR microcontroller to achieve the 485 communication from the machine to receive procedures (with frame check), single-chip microcomputer).docVIP
- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
avr单片机实现的485通讯从机接收程序(带帧校验)单片机(AVR microcontroller to achieve the 485 communication from the machine to receive procedures (with frame check), single-chip microcomputer)
avr单片机实现的485通讯从机接收程序(带帧校验)单片机(AVR microcontroller to achieve the 485 communication from the machine to receive procedures (with frame check), single-chip microcomputer) AVR MCU 485 communication receiving program from the machine (with frame check) chip 2009-08-31 14:15:48 read 442 comments 0 small subscription number: / / slave program The //01 data frame //02 command frame //03 frame 01 confirmed 02 deny #includeavr/io.h #includeavr/interrupt.h #includeinttypes.h #includeutil/delay.h #include avr/pgmspace.h #includestring.h #define myaddr 0x01 / / define the address of the machine #define (rx_485); ASM (CBI 0x13,2); //portd.2 cleared to the receiving state #define (tx_485); ASM (SBI 0x13,2); //portd.2 is set to send state Volatile struct conn{ Unsigned char buf[70]; Unsigned char data[64]; Unsigned char srcadd; / / source address Unsigned char aimadd; / / destination address Unsigned char TP; / / frame type Int num; Int tmp; Unsigned char ver; / / verification code; Unsigned char err; / / error code; 01: frame check. }tx, rx; Volatile unsigned char com; / / command Const unsigned char flash_str[] PROGMEM = 0123456789; ISR (USART_RXC_vect) { Rx.buf[rx.tmp]=UDR; /*test If (rx.tmp==0 and rx.buf[rx.tmp]==t) { (totx); Tx.num=16; Strcpy (tx.buf, can I help you); Tx.buf[15]=0x0D; UCSRB|= (1UDRIE); / / send frame }; * / If (rx.tmp==0 rx.buf[rx.tmp]! =myaddr) / / return directly to the wrong address { Receive 0.15 seconds / / ban. Feasible, because the use of interrupt mode, does not affect the normal use UCSRB=~ (1RXEN); //0.15 seconds after the automatic entry into the receiving state. (timer1_init); Return; }; If ((rx.tmp4) (rx.tmp==rx.buf[3]+4) (rx.buf[rx.tmp]! =rx.ver)) / / validation error { When receiving / / after the end, what things are not dry, just waiting to receive. Rx.err=0x01; }; If ((rx.tmp4) (rx.tmp==rx.buf[3]+5) rx.err==0 (rx.buf[rx.tmp]==0xcc)) / / normal end { / / frame type case / / deny frame or confirmation frame or other frame TCCR2 = 0
您可能关注的文档
- 6级人防覆土2米等效静荷载多少(What is the equivalent static load of 6 meters covered with air defense 2 meters).doc
- 6陈安之告诉你-超级快速致富秘诀(6 Chen Anzhi tells you - super quick tips for getting rich).doc
- 7 商店建筑设计规范(7 code for design of shop building).doc
- 7.工期保证措施(7. time limit guarantee measures).doc
- 72非风湿性二尖瓣返流疾病(72 non rheumatic mitral regurgitation disease).doc
- 74-中国船级社广州分社海关监管集装箱式货车车厢申请及检验流程(74- China Classification Society, Guangzhou branch, customs supervision, container type freight car application and inspection process).doc
- 76uut(76uut).doc
- 7.4__dll函数入口及其导出函数(7.4__dll function entry and its export function).doc
- 75-3和75-5视频线参数(75-3 and 75-5 video line parameters).doc
- 770-南京市优秀专利奖(770- Nanjing excellent Patent Award).doc
- a开头的易错成语(At the beginning of the a error prone idioms).doc
- a方太的企业文化(A FOTILE's corporate culture).doc
- a级面介绍(Level a presentation).doc
- avi所需插件下载及各个插件用途(Avi plug-in download and the use of plug-ins).doc
- autocad 常用快捷键(autocad 常用快捷键).doc
- atmega32熔丝位设置终于成功(Atmega32 fuse bit setting finally succeeded).doc
- a股主力操盘密码破译(A major trader cryptographers).doc
- b2b上的新活法在线交易缩短供应链(The new law on B2B online transactions to shorten the supply chain).doc
- b6ac中文(B6ac Chinese).doc
- b6充电器使用说明书(B6 charger manual).doc
文档评论(0)