• PicŪ Basic


  • Re: CCITT CRC16 [CRC-16] Routines

    What I use. Pulled and modified from the ether somewhere

    Dim CRC As Word ;CRC16 value
    Dim CRC_P As Byte ;Data Array pointer
    Dim CRC_B As Byte ;Transfer Buffer
    Dim CRC_C As Byte ;Counter
    Dim SArray[10] as Byte ;Array of data to do CRC on

    ;Generate CRC
    Clear CRC
    For CRC_P = 0 To 9
    CRC_B = SArray[CRC_P]
    Call CRC16
    Next CRC_P
    'CRC now has CRC-16


    ; CRC-16 (x^16+x^15+x^2+x^0)
    ; Input: CRC_B = Data byte for CRC calculation
    ;************************************************* *******************
    CRC16: ;Note:- CRC is a word. CRC =>LowByte, CRCH =>HighByte
    Asm
    Movlw 8
    Movwf CRC_C ;Load bit counter
    CRC_Loop:
    Movf CRC,W ;Low byte
    Xorwf CRC_B,W
    Clrc
    Rrf CRCH ;High byte
    Rrf CRC ;Low byte
    Andlw 1
    Bz CRC_Skip
    Movlw 0xA0
    Xorwf CRCH ;High byte
    Movlw 0x01
    Xorwf CRC ;Low byte
    CRC_Skip:
    Rrf CRC_B
    Decfsz CRC_C
    Jump CRC_Loop
    EndAsm
    Return

    See http://www.lammertbies.nl/comm/info/...lculation.html as a good place to check your code working etc
    This article was originally published in forum thread: CCITT CRC16 [CRC-16] Routines started by pciebiera View original post
  • Recent Activity

    teo-16018

    Microsoft security essentials blues

    Thread Starter: shantanu@india

    Hi, A strange thing happened just now.My Windows 7 Micrsoft Sercurity Essentials suddenly gave a warning that prplus.exe(Compiler) is a potential...

    teo Today, 19:23 Go to last post
    pic-ignorant-1162

    Proton Runtime Error

    Thread Starter: Paulcc

    I have proton running well on my laptop, but after installing it on my desktop, I get the following runtime error: "Runtime Error 217 at 000709FC" I...

    pic-ignorant Yesterday, 22:11 Go to last post
    David Barker-251

    UMC bootloader 18F46K22

    Thread Starter: shunt010

    Hi all. I am trying to build a UMC bootloader file for the 18F46K22, and it doesn't appear to work. It returns (in the error log) Error ...

    David Barker Today, 11:20 Go to last post
    barak-1433

    SPI mssp

    Thread Starter: picprotonguy

    Just ordered Digital to Analog IC MCP4822 with SPI interface and immediately opened proton manual. I'm very disappointed, it looks like Proton...

    barak Today, 16:06 Go to last post