• 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

    towlerg-21522

    FineLineIDE

    Thread Starter: normnet

    Coming soon a new IDE: FineLineIDE! Features include:<O:p</O:p Bracket lines linking If-Endif, For-Next etc.<O:p</O:p Tabbed explorer so...

    towlerg Yesterday, 13:36 Go to last post
    Henk57-24049

    Compiler 3.6.1.7 issue with 16F1829 and I2C-LCD

    Thread Starter: Henk57

    Spend this afternoon with a compiler issue; no error's, but my LCD give only first line with squares, no characters, nothing. If I flash an old .hex...

    Henk57 Yesterday, 19:31 Go to last post
    hadv215-2509

    CData Table

    Thread Starter: Beginner

    Is there perhaps the possibility to extend the IDE with a 'Raw Flash' command? Currently I have the huge problem that if I want to program a web page...

    hadv215 Yesterday, 22:41 Go to last post
    Henk57-24049

    Pulse counter using COUNTER command

    Thread Starter: amod

    How I can use counter command for counting pulses on portd.3 of 16f877A.Iam making a 8 digit object counter.

    Henk57 Yesterday, 19:43 Go to last post