热水壶厂家
免费服务热线

Free service

hotline

010-00000000
热水壶厂家
热门搜索:
技术资讯
当前位置:首页 > 技术资讯

PIC单片机实现CRC的小程序

发布时间:2020-06-30 20:26:16 阅读: 来源:热水壶厂家

PIC单片机实现CRC的小程序PIC单片机实现Dallas的iButton通讯时,编了段产生和校验CRC的子程序。;PIC单片机 #C>;-------------------------------cblock0x20datBuff:8;assign8bytedatabufferbit_cnt;bitcountingCRC_COUNT;numberofbytesforCRCCRC_RESULT;CRCresulrcrc_temp;temporarydatabufferduringCRCendc;-------------------------------#defineskp0btfsc#defineskp1btfss;===============================org0x000movlw.7movwfCRC_COUNTmovlwdatBuffmovwfFSR;FSRpointtodatabuffercallCRC_CHECKmovwfdatBuff+7goto$;===============================;CHECKTHECRCFOR?BYTESDATA;ForthepolynomialofX^8+X^5+X^4+1;DerivedfromDallas'siButtonstandard;Beforecalling,FSR=databuffer;CRC_COUNT=numberofbytesforCRCCRC_CHECK;~~~~~~~~~~~~~~~clrfCRC_RESULT;initializetheCRCbuffer_crc_00movlw.8;numberofbitsforonebytemovwfbit_cnt;setbitcountermovfINDF,w;getonedatabytemovwfcrc_temp;copytotemporarylocation_crc_01rrfcrc_temp,f;getLSBinCskpc;isthisLSB=1?goto_crc_02;goifLSB=0movlw0x01;doifLSB=1xorwfCRC_RESULT,f_crc_02rrfCRC_RESULT,w;getLSBofCRCskpc;testLSBgoto_crc_03;goifLSB=0movlw0x18;doifLSB=1xorwfCRC_RESULT,f;polynomialimplementation_crc_03rrfCRC_RESULT,w;wholebyterightrotaterrfCRC_RESULT,fdecfszbit_cnt,f;bitcountinggoto_crc_01;goonuntilaa8bitsdoneincfFSR,f;pointerupdatetonextbytedecfszCRC_COUNT,f;bytecountinggoto_crc_00;goonuntilallbytedonemovfCRC_RESULT,w;getCRC,ZsetifCRC=0return;returnwithCRCinWEND

订做工作服

临沂订做防静电工服

枣庄定制西装

威海西装订做