Proton BASIC Compiler - OW_CRC

  • Pic® Basic

  • OW_CRC

    A library module for use with Library Manager by JohnGB. This module has been written by Tim Box (Tim on PDS forum). The library module is offered on an as-is basis with no warranty as to its effectiveness, operation or reliability. Users use it at their own risk.

    Adds a new command called OW_CRC


    Var = OW_CRC DataArray, Length


    Returns the result of the Dallas One-Wire™ CRC calculation performed on the data set in DataArray. If the result is 0 the CRC is OK. A non-zero value indicates a CRC failure.


    DataArray – A Valid label to the One-Wire™ Array on which the CRC Calculations will be executed

    Length – A byte size variable defining the number of bytes within the array to be checked.

    Dim TestData[8] As Byte
    Dim CRCResult As Byte
        ' Load up Data array
        TestData[0] = $05
        TestData[1] = $C5
        TestData[2] = $C3
        TestData[3] = $08
        TestData[4] = $00
        TestData[5] = $00
        TestData[6] = $00
        TestData[7] = $CD  'CRC
        CRCResult = OW_CRC TestData, 8
        If CRCResult = 0 Then
            HRSOut "CRC OK",10,13
            HRSOut "CRC Error ", HEX2 CRCResult,10,13

    The Array should be set to the maximum size message that you expect to have to handle from the One-Wire devices.

    The length parameter should be the actual length of the message currently held in the array and should include the CRC value in the last byte.

    Download module

    Download: OW_CRC_Calcs