Author Topic: Calculating CRC in the automotive induatry, but how?  (Read 346 times)

0 Members and 1 Guest are viewing this topic.

Offline Chriss

  • Frequent Contributor
  • **
  • Posts: 308
  • Country: 00
Calculating CRC in the automotive induatry, but how?
« on: September 21, 2019, 11:51:42 pm »
Hi!
Today a was talking with a friend abkut  electronic, software etc.
He is in the field of car electronic repairing and he asked me an interesting question.
He asked me to explain how som ecu in the car calc the crc for the eep of the ecu.
He also told me does sometime he have to change some info in the eep dump a d he have a crc error after the changing.

He will share some  examples cos I really curious how that looks like and how they do the math.

If somebody here have some algo or explanation how that is working on the auto industry, I would like to read about.

Thanks for any info.
 

Offline oPossum

  • Frequent Contributor
  • **
  • Posts: 828
  • Country: us
  • The other white meat
Re: Calculating CRC in the automotive induatry, but how?
« Reply #1 on: September 22, 2019, 12:05:12 am »
CRC explained in detail...





Short answer is that you need to know the polynomial, initial value, and bit order to be able to calculate the CRC. The actual math is simple.

Code: [Select]
void crc_init(void)
{
crc = 0xFFFF;
}

void crc_update(uint16_t *d, unsigned len)
{
while (len--) {
crc ^= *d++;
unsigned n = 16;
do crc = (crc & 0x8000) ? (crc << 1) ^ 0x1021 : crc << 1; while (--n);
      }
}
 
The following users thanked this post: Chriss

Online ataradov

  • Super Contributor
  • ***
  • Posts: 5940
  • Country: us
    • Personal site
Re: Calculating CRC in the automotive induatry, but how?
« Reply #2 on: September 22, 2019, 12:06:37 am »
There is no universal "auto industry" CRC, if that's what you are asking. So it all happens on a case by case basis.
Alex
 
The following users thanked this post: Chriss


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf