📄 cetinet 中国电子技术信息网——51系列单片机-crc16校验的程序.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0044)http://www.cetinet.com/t_mcu/list.asp?id=261 -->
<HTML><HEAD><TITLE>cetinet 中国电子技术信息网——51系列单片机-CRC16校验的程序</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#f3f3f3>
<META content="Microsoft FrontPage 4.0" name=GENERATOR>
<META content=FrontPage.Editor.Document name=ProgId><LINK
href="cetinet 中国电子技术信息网——51系列单片机-CRC16校验的程序.files/style.css" type=text/css
rel=stylesheet>
<STYLE type=text/css>BODY {
SCROLLBAR-FACE-COLOR: #5b9595; SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; SCROLLBAR-SHADOW-COLOR: #ffffff; SCROLLBAR-3DLIGHT-COLOR: #ffffff; SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-TRACK-COLOR: #ffffff; SCROLLBAR-DARKSHADOW-COLOR: #ffffff
}
</STYLE>
<DIV align=center>
<TABLE height=60 cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD width=200><A href="http://www.cetinet.com/"><IMG
src="cetinet 中国电子技术信息网——51系列单片机-CRC16校验的程序.files/myad.gif"
border=0></A></TD>
<TD width=275>
<DIV align=right>
<P align=center><A href="http://www.cetinet.com/t_mcu/images/ad.asp"
target=_blank><IMG
src="cetinet 中国电子技术信息网——51系列单片机-CRC16校验的程序.files/ad.gif" border=0></A>
</P></DIV></TD>
<TD width=275>
<P align=center><A href="http://www.cetinet.com/t_mcu/images/adsmall.asp"
target=_blank><IMG
src="cetinet 中国电子技术信息网——51系列单片机-CRC16校验的程序.files/adsmall.gif"
border=0></A></P></TD></TR></TBODY></TABLE><BR>
<TABLE height=20 cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD align=middle width=81 bgColor=#5b9595><A
href="http://www.cetinet.com/" target=_blank><FONT
color=#ffffff>本站首页</FONT></A></TD>
<TD align=middle width=60 bgColor=#d7e3e3><A
href="http://www.cetinet.com/bbs/index.asp" target=_blank>技术论坛</A></TD>
<TD align=middle width=60 bgColor=#d7e3e3><A
href="http://www.cetinet.com/t_mcu/index.asp" target=_blank>微控制器</A></TD>
<TD align=middle width=61 bgColor=#d7e3e3><A
href="http://www.cetinet.com/t_fpga/index.asp" target=_blank>IC 设 计</A></TD>
<TD align=middle width=61 bgColor=#d7e3e3><A
href="http://www.cetinet.com/t_eda/index.asp" target=_blank>EDA 技术</A></TD>
<TD align=middle width=61 bgColor=#d7e3e3><A
href="http://www.cetinet.com/t_circuitry/index.asp"
target=_blank>电路基础</A></TD>
<TD align=middle width=61 bgColor=#d7e3e3><A
href="http://www.cetinet.com/t_power/index.asp" target=_blank>电源技术</A></TD>
<TD align=middle width=61 bgColor=#d7e3e3><A
href="http://www.cetinet.com/t_comm/index.asp" target=_blank>通信技术</A></TD>
<TD align=middle width=61 bgColor=#d7e3e3><A
href="http://www.cetinet.com/t_meterage/index.asp"
target=_blank>测试测量</A></TD>
<TD align=middle width=61 bgColor=#d7e3e3><A
href="http://www.cetinet.com/t_other/index.asp" target=_blank>综合技术</A></TD>
<TD align=middle width=61 bgColor=#d7e3e3><A
href="http://www.cetinet.com/t_program/index.asp"
target=_blank>编程学堂</A></TD>
<TD align=middle width=61 bgColor=#d7e3e3><A
href="http://www.cetinet.com/download/Default.asp"
target=_blank>下载中心</A></TD></TR></TBODY></TABLE><BR></DIV>
<DIV align=center>
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD>您目前的位置:<A href="http://www.cetinet.com/t_mcu/index.asp">技术文章</A> - <A
href="http://www.cetinet.com/t_mcu/step.asp?id=9">51系列单片机</A> -
CRC16校验的程序</TD></TR></TBODY></TABLE>
<DIV align=center>
<TABLE height=250 cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD vAlign=top width=150 bgColor=#5b9595 height=240>
<TABLE cellSpacing=0 width=150 border=0>
<TBODY>
<TR>
<TD height=20></TD></TR>
<TR>
<TD height=20><FONT color=#ffffff>文章类别:</FONT></TD></TR>
<TR>
<TD height=20>
<P align=center><FONT color=#f3f3f3>51系列单片机</FONT></P></TD></TR>
<TR>
<TD height=20><FONT color=#ffffff>文章来源:</FONT></TD></TR>
<TR>
<TD height=20><FONT color=#f3f3f3>
<P align=center>未知</FONT></P></TD></TR>
<TR>
<TD height=20><FONT color=#ffffff>文章作者:</FONT></TD></TR>
<TR>
<TD height=20><FONT color=#f3f3f3>
<P align=center>未知</FONT></P></TD></TR>
<TR>
<TD height=20><FONT color=#ffffff>关 键 字:</FONT></TD></TR>
<TR>
<TD height=20><FONT color=#f3f3f3>
<P align=center>CRC16</FONT></P></TD></TR>
<TR>
<TD height=20><FONT color=#ffffff>今天阅读:</FONT></TD></TR>
<TR>
<TD height=20><FONT color=#f3f3f3>
<P align=center>8</FONT></P></TD></TR>
<TR>
<TD height=20><FONT color=#ffffff>总共阅读:</FONT></TD></TR>
<TR>
<TD height=20><FONT color=#f3f3f3>
<P align=center>1504</FONT></P></TD></TR>
<TR>
<TD height=20><FONT color=#ffffff>加入日期:</FONT></TD></TR>
<TR>
<TD height=20><FONT color=#f3f3f3>
<P align=center>2002-9-12 11:14:37</FONT></P></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 width=150 border=0>
<TBODY>
<TR>
<TD height=20>
<DIV align=center><FONT color=#ffffff>==相关文章==</FONT></DIV></TD></TR>
<TR>
<TD height=20>
<DIV align=center><FONT
color=#ffffff>还没有任何相关文章</FONT></DIV></TD></TR></TBODY></TABLE></TD>
<TD vAlign=top width=600 height=240>
<TABLE height=20 cellSpacing=0 cellPadding=0 width=600 border=0>
<TBODY>
<TR>
<TD bgColor=#5b9595> </TD></TR></TBODY></TABLE>
<TABLE cellSpacing=3 cellPadding=0 width=600 border=0>
<TBODY>
<TR>
<TD bgColor=#aecece height=20>
<DIV align=center><FONT
color=#0a52d8><B>CRC16校验的程序</B></FONT></DIV></TD></TR>
<TR>
<TD
width=600>CRC16校验的程序<BR><BR>;==========================================================<BR> DATA_BUFF EQU 10H<BR> CRC_NUM EQU 22H<BR> CRC_DATA EQU 23H<BR> CRC_POINTER EQU 30H<BR>;==========================================================<BR> CRC_XORH EQU 10H ;11021=2^16+2^12+2^5+1<BR> CRC_XORL EQU 21H<BR>;==========================================================<BR> ORG 0000H<BR> AJMP MAIN<BR>MAIN: MOV CRC_DATA,#DATA_BUFF<BR> MOV CRC_NUM,#3<BR> ACALL CRC<BR> AJMP MAIN<BR>;==========================================================<BR>; *****RC校验子程序*****<BR>; 多项式=2^16+2^12+2^5+1=11021H<BR>;CRC_DATA-----进行CRC校验的数据指针,保存需要进行CRC校验的数据首址<BR>;CRC_POINTER--缓冲保存CRC校验数据首址<BR>;CRC_NUM------保存所需进行CRC校验的字节数<BR>;R7-----------所有进行CRC校验字节的位数,=(CRC_NUM+2)*8-16<BR>;==========================================================<BR>CRC: MOV R0,CRC_DATA<BR> MOV R1,#CRC_POINTER<BR> MOV R2,CRC_NUM<BR> MOV A,CRC_NUM ;R7=CRC_NUM*8<BR> ADD A,#2<BR> RL A<BR> RL A<BR> RL A<BR> CLR C<BR> SUBB A,#16 ;CRC码为2个字节,16位<BR> MOV R7,A<BR>CRC1: MOV A,@R0 ;缓存原数据<BR> MOV @R1,A<BR> INC R0<BR> INC R1<BR> DJNZ R2,CRC1<BR> CLR A ;在原数据后添加2个零字节<BR> MOV @R1,A<BR> INC R1<BR> MOV @R1,A<BR>CRC2: MOV A,#CRC_POINTER ;从最后一个字节开始左移一位<BR> ADD A,CRC_NUM ;共有CRC_NUM+2个字节<BR> ADD A,#1 ;最后一个数据地址为<BR> MOV R0,A ;R0=CRC_POINTER+CRC_NUM+2-1<BR> MOV A,CRC_NUM ;计算参与移位计算的字节数<BR> ADD A,#2 ;保存在R1中<BR> MOV R1,A ;R1=CRC_NUM+2<BR> CLR C<BR>CRC3: MOV A,@R0<BR> RLC A<BR> MOV @R0,A<BR> DEC R0<BR> DJNZ R1,CRC3 ;判断每移动一位,所有参与移位的字节是否移完<BR> JNC CRC4 ;进行异或条件判断<BR> MOV A,#CRC_XORH<BR> XRL A,CRC_POINTER<BR> MOV CRC_POINTER,A<BR> MOV A,#CRC_XORL<BR> XRL A,CRC_POINTER+1<BR> MOV CRC_POINTER+1,A<BR>CRC4: DJNZ R7,CRC2 ;判断移位是否结束<BR><BR>CRC_END:<BR> RET</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></DIV>
<DIV align=center><BR><BR>
<P align=center>本站所载文章力求原创,部分资料转自网上,假如您认为某些文章侵犯了您的权益,<BR>请<A
href="mailto:aoe@cetinet.com">告知我们</A>,我们将在最短的时间内删除有关文章。本站转载文章均注明出处。<BR>兄弟网站如果转载本站文章请注明本站版权,谢谢!
<P align=center>cetinet 文章管理系统由:<A href="mailto:aoe@cetinet.com">aoe</A>
制作<BR>Copyright (C) 2001 <A href="http://www.cetinet.com/"
target=_blank>http://www.cetinet.com/</A> All Rights Reserved
</P></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -