给大家提供一个CRC校验的例程===正在学习自由口通讯的要好好看看

已锁定

*静 水*

  • 帖子

    526
  • 精华

    1
  • 被关注

    14

论坛等级:侠客

注册时间:2006-05-10

普通 普通 如何晋级?

给大家提供一个CRC校验的例程===正在学习自由口通讯的要好好看看

4892

9

2011-01-22 17:32:53

Network 1 // MBUS_CRC - Calculate a CRC.
//
// Calculate CRC
//
// This subroutine calculates the CRC value for the message using the slightly
// faster table lookup method. The CRC is calculated on modbusBufr using the
// first byte of this buffer as the byte count. The CRC is written into the
// buffer after the data.
//
// NOTE: This routine requires about 650 uSec per byte to calculate the
// CRC (i.e. 65 mSec for 100 bytes).
//
// Inputs: none
//
// Outputs: crc CRC value
//
//
LD SM0.0 //
BTI VB100, LW2 // get the byte count
MOVD &VB100, LD4 // get buffer address for CRC check
INCD LD4 // point to first message byte
XORD AC0, AC0 // clear temporary register
MOVD 16#FFFF, AC2 // initialize the CRC value to 0xFFFF

FOR AC1, +1, LW2 // for all bytes in the message
MOVB *LD4, AC0 // get the message byte
XORW AC2, AC0 // XOR CRC with data
ANDW 16#FF, AC0 // keep only the LSByte
SLW AC0, 1 // convert to an index into word table
MOVD &VB356, AC3 // get start of table address
+I AC0, AC3 // add index to table start
SWAP AC2 // swap bytes of CRC
ANDW 16#FF, AC2 // keep only the LSByte
XORW *AC3, AC2 // OR table value with CRC
INCD LD4 // point to the next message byte
给大家提供一个CRC校验的例程===正在学习自由口通讯的要好好看看 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-200

共有33257条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。