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

0 Members and 1 Guest are viewing this topic.

Offline ChrissTopic starter

  • Frequent Contributor
  • **
  • Posts: 534
  • 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.
 

Online oPossum

  • Super Contributor
  • ***
  • Posts: 1415
  • Country: us
  • Very dangerous - may attack at any time
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: 11236
  • 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