Help using crc8

I've been trying to use Rob Tillaart's crc8 library with no success and the problem is I have absolutly no idea how to use it, I've looked at examples and read what I can find but I'm not a programmer and am no closer than I was to start with basically I want to generate a crc8 checksum from three bytes of data, I have the polynome, initial value and Xor output values but have absolutley no idea how to implement it

This is my code stripped out to the bare minimum just needs the crc8 part any help would be much appreciated

//written for teensy 3.2

#include "CRC8.h"
#include "CRC.h"

CRC8 crc;

int counter = 0;
uint8_t initial=0x0;
uint8_t xorOut=0x70;
uint8_t polynome=0x1D;
 
#include <FlexCAN.h>
#include <SPI.h>


CAN_message_t msg;
CAN_message_t inMsg;

void setup() {
Can0.begin(500000);

}


void loop() {

    msg.id  = 0x3fd;
    msg.len = 7;
    msg.buf[0] = 0;      //checksum   polynome = 0x1D,   initial value = 0x0,   xor_output = 0x70
    msg.buf[1] = counter;//counter

    // checksum needs to be applied to the following three bytes and entered into msg.buf[0]
    msg.buf[2] = 0x81;   //payload byte 1
    msg.buf[3] = 0;      //payload byte 2
    msg.buf[4] = 0;      //payload byte 3

     
    msg.buf[5] = 0;//always 0
    msg.buf[6] = 0;//always 0
    msg.buf[7] = 0;//always 0

    Can0.write(msg);delay(2);
    counter++;
    if (counter == 16){counter=0;}

}

where does this come from?

is that specified for your system ?

Hello andybp

Good day.
I feel you need to explain some more on your project.
On base of your details I feel you like to sent some messages on a CAN network.
Then FlexCAN is "near" the same a normal CAN. You can have a look to the Lib Manager inside Arduino IDE. Then check the more information. This will lead to a link to github with more details. There you can see under examples a CAN sending ino. The CRC calculation will be done inside the CAN driver package and you do not take care on this.
CAN package
Or is your goal to find out how a CRC code will work?

Please explain more.

Best regards Mascho

my problem is I have no idea how to use the crc8 library i have included it and set the three variables required but that is all I have no idea how to use it and had hoped someone would know how to use this library

To see how to use Rob Tillaart's crc8 library, study and run the CRC8_test example in the library. Reading the library documentation is also highly recommended.

With any new Arduino library, always start by running one or more of the provided examples.

all of which I have done it did not help
I am not a programmer I don't understand where to start

There are a couple of ways to go.

One is to start at the beginning and learn the programming language, as well as the special features of the Arduino microcontroller platform. The Arduino IDE has lots of examples built in, and there are many more on line, along with countless tutorials.

The other approach is to have someone write the code for you. Post on the Jobs and Paid Collaboration forum section, and be prepared to pay for the effort.

as I thought I'd explained I was having difficulty understanding how to use the library and just really needed some one to explain it a little but don't worry I wrote my own code to calculate the crc8 checksum it was easier than getting any kind of explanation or advice it seems

To be honest you did not answer the couple questions at the start which were to investigate the details of your needs before providing additional help…

Glad you solved it by yourself

It should probably look something like this. It may need to be adjusted depending on which bytes are actually supposed to be included in the CRC (for instance, is msg[0] supposed to be included,
perhaps with some specified initial value? What about the "must be zero" bytes?)

#include "CRC8.h"
#include "CRC.h"

CRC8 crc(0x1d, 0, 0x70, false, false); // define the CRC parameters.
// :

void loop() {
    msg.id  = 0x3fd;
    msg.len = 7;
    msg.buf[0] = 0;      //checksum   polynome = 0x1D,   initial value = 0x0,   xor_output = 0x70
    msg.buf[1] = counter;//counter
    msg.buf[2] = 0x81;   //payload byte 1
    msg.buf[3] = 0;      //payload byte 2
    msg.buf[4] = 0;      //payload byte 3
    msg.buf[5] = 0;//always 0
    msg.buf[6] = 0;//always 0
    msg.buf[7] = 0;//always 0
//
// Fill in the CRC
    crc.restart();                  // reset crc value
    crc.add(&msg.buf[1], msg.len);  // compute the crc for all 7 bytes (address, length)
    msg.buf[0] = crc.calc();        // fill it in where it's supposed to be
//
    Can0.write(msg);delay(2);
    counter++;
    if (counter == 16){counter=0;}
}

[/quote]