C2000 Launchpad Problem with XOR Calculation

Hello everyone,
I am using an TMS320F28377S C2000 Launchpad from Texas Instruments with Matlab R2017b and the Embedded Coder Support Package for Texas Instruments C2000 Processors. I currently have a problem with a checksum calculation, which I can not get any further, so I hope someone can help me here.
My board gets a message via CAN A, wich I unpack and pass on as raw data u (vector with values between [0;255]). For this data, I calculate a checksum [0;255] in a MATLAB function and give it with the data to the second CAN.
To calculate the checksum, I perform 6 XOR operations and take a value from a table each time:
checksum = 255;
for i = 2:7
checksum = bitxor(checksum, u(i));
checksum = table(checksum + 1);
end
Here's a problem: sometimes my launchpad calculates a wrong value (In most cases, it works, but not every time). However, if I do the same calculation in a Matlab script on my PC, the right value for the specific data will come out. I suspect the error may be related to the data types or settings in the Model Configuration Parameters, but I don't know how to solve the problem...
The problem does not seem to be related to CAN Hardware, because it reads in the data correctly and passes it on. If, after the calculation, I compare the determined value with the target value, the error is already detected. So the wrong value is still there before transmitting it via CAN Bus.
I hope, here maybe someone knows what it could be. I've already tried casting the bytes as uint8, but that did not fix the problem...

Answers (0)

Products

Release

R2017b

Asked:

on 4 Jun 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!