中文字幕无码不卡一区二区三区_少妇被又大又粗又爽毛片久久黑人_91精品国产在热久久无毒不卡_久久久久久亚洲综合网站

技術(shù)熱線: 4007-888-234
設(shè)計(jì)開發(fā)

專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命

開發(fā)工具

提供開發(fā)工具、應(yīng)用測試 完善的開發(fā)代碼案例庫分享

技術(shù)支持

從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無限潛能!

新品推廣

提供新的芯片及解決方案,提升客戶產(chǎn)品競爭力

新聞中心

提供最新的單片機(jī)資訊,行業(yè)消息以及公司新聞動(dòng)態(tài)

PIC單片機(jī)實(shí)現(xiàn)CRC的小程序

更新時(shí)間: 2019-03-22
閱讀量:1579

單片機(jī)開發(fā)商深圳英銳恩分享PIC單片機(jī)實(shí)現(xiàn)CRC的小程序。PIC單片機(jī)實(shí)現(xiàn)Dallas的iButton通訊時(shí),編了段產(chǎn)生和校驗(yàn)CRC的子程序。
    #include 

;-------------------------------
    cblock    0x20
datBuff:8            ;assign 8 byte data buffer
bit_cnt                ;bit counting 
CRC_COUNT            ;number of bytes for CRC
CRC_RESULT            ;CRC resulr
crc_temp            ;temporary data buffer during CRC
    endc

;-------------------------------
#define    skp0    btfsc
#define    skp1    btfss


;===============================
    org    0x000

    movlw    .7
    movwf    CRC_COUNT
    movlw    datBuff
    movwf    FSR        ;FSR point to data buffer
    call    CRC_CHECK
    movwf    datBuff+7
    goto    $

;===============================
;CHECK THE CRC FOR ? BYTES DATA
;For the polynomial of X^8 + X^5 + X^4 + 1
;Derived from Dallas's iButton standard
;Before calling, FSR       = data buffer
;                CRC_COUNT = number of bytes for CRC
CRC_CHECK    ;~~~~~~~~~~~~~~~
    clrf    CRC_RESULT    ;initialize the CRC buffer
_crc_00
    movlw    .8        ;number of bits for one byte
    movwf    bit_cnt        ;set bit counter
    movf    INDF,w        ;get one data byte
    movwf    crc_temp    ;copy to temporary location

_crc_01
    rrf    crc_temp,f    ;get LSB in C
    skpc            ;is this LSB=1?
    goto    _crc_02        ;go if LSB=0
    movlw    0x01        ;do if LSB=1
    xorwf    CRC_RESULT,f
_crc_02
    rrf    CRC_RESULT,w    ;get LSB of CRC
    skpc            ;test LSB
    goto    _crc_03        ;go if LSB=0
    movlw    0x18        ;do if LSB=1
    xorwf    CRC_RESULT,f    ;polynomial implementation
_crc_03
    rrf    CRC_RESULT,w    ;whole byte right rotate
    rrf    CRC_RESULT,f
    decfsz    bit_cnt,f    ;bit counting
    goto    _crc_01        ;go on until aa 8 bits done
    incf    FSR,f        ;pointer update to next byte
    decfsz    CRC_COUNT,f    ;byte counting
    goto    _crc_00        ;go on until all byte done
    movf    CRC_RESULT,w    ;get CRC, Z set if CRC=0
    return            ;return with CRC in W

 END

隆尧县| 蒲江县| 连平县| 富顺县| 大足县| 永定县| 马关县| 惠州市| 延庆县| 鄂尔多斯市| 疏勒县| 天峻县| 普兰县| 武义县| 赣州市| 利辛县| 青铜峡市| 米林县| 工布江达县| 溧水县| 屯留县| 梁河县| 始兴县| 安溪县| 西乌珠穆沁旗| 搜索| 葵青区| 定远县| 南涧| 永城市| 淄博市| 保德县| 彭泽县| 西贡区| 莎车县| 贵州省| 邵阳市| 手机| 油尖旺区| 随州市| 扶绥县|