Hi everyone I am working on SSP (simple serial protocol) and I'm trying to test the code in the attached picture using only one Arduino any help how can I do this
TIA ![]()
By typing it in. We want to see your sketch, in code tags please. If you want to run something only once, put it in setup().
Put that code in s function that takes arguments char * bufp and int len and returns unsigned short. Calculate CRC and return the value. Pass the function various known patterns and check that the value returned is what you expect.
#define POLY 0x8408 /* bits reversed for LSB-first */
unsigned short crc = 0xffff;
while (len-- > 0)
{
unsigned char ch = *bufp++;
for (i = 0; i < 8; i++)
{
crc = (crc >> 1) ˆ ( ((ch ˆ crc) & 0x01) ? POLY : 0 ); ch >>= 1;
}
}
that is the code can you illustrate more please thanks alot
Is this a school assignment? AVR C++ has built in CRC functions that you can use.
#include <util/crc16.h>
uint16_t make_crc(uint8_t* sourceArray, uint8_t arraySize)
{
 uint16_t crc = 0;
 for (uint8_t i = 0; i < arraySize; i++)
 {
  crc = _crc16_update(crc, sourceArray[i]);
 }
 return crc;
}
aarg:
Is this a school assignment? AVR C++ has built in CRC functions that you can use.#include <util/crc16.h>
uint16_t make_crc(uint8_t* sourceArray, uint8_t arraySize)
{
uint16_t crc = 0;
for (uint8_t i = 0; i < arraySize; i++)
{
crc = _crc16_update(crc, sourceArray[i]);
}
return crc;
}
not school assignment no
university project and my supervisor wants it to be tested using Arduino
thank you
The example I posted shows you how to follow John Wasser's advice.
aarg:
The example I posted shows you how to follow John Wasser's advice.
yes thanks a lot
