crc 8 bit

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i need to compute an 8 bit crc of ten bytes blocks, (assembly code)
any ideas???

pavel

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

is 16-bit Fletcher's algorithm better then crc-8 ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That I don't know. I suspect that 16-bit algorithm must be more reliable than 8-bit. On a second thought, for 10-byte blocks even 8-bit should be enough.

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sensirion uses CRC8 in their humidity sensors.
They have an appnote where they describe the algorithm.
It's very easy to do it in assembly.

Or just do the checksum(=EOR).

Practice Safe hex.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See http://avr.vfx.hu and try xmodem.asm. Its contains this (Xmodem CRC16):
~30 cycles compute CRC16

;***************************************************************************
;** Calc & Update XMODEM CRC
;*
;* In: R0 - data byte

UpdateCRC:
lds R17,CRC+1
mov R15,R17
swap R17
mov R16,R17

eor R17,R15
andi R17,0xF0
andi R16,0x0F
eor R15,R16

mov R14,R17
lsl R14
rol R16

eor R15, R14
eor R17,R16

lds R14,CRC+0
eor R15,R0
eor R17,R14

sts CRC+0,R15
sts CRC+1,R17
ret

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kkontak wrote:
Sensirion uses CRC8 in their humidity sensors.

Dallas (Maxim) also use an 8-bit CRC in their 1-Wire(TM) products - so you could also check any 1-Wire device datasheet..

However, for a complete treatment of the topic, including code generation, see this excellent article:
http://www.repairfaq.org/filipg/LINK/F_crc_v3.html

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

//
// calculate a Dallas CRC8 checksum
//
static uint8_t calc_crc8(uint8_t* data_pointer, uint8_t number_of_bytes)
{
	uint8_t temp1, bit_counter, feedback_bit, crc8_result=0;
	
	while(number_of_bytes--)
    {
		temp1= *data_pointer++;
		
        for(bit_counter=8; bit_counter; bit_counter--)
        {
			feedback_bit=(crc8_result & 0x01);
			crc8_result >>= 1;
			if(feedback_bit ^ (temp1 & 0x01))
			{ 
				crc8_result ^= 0x8c;
			}
			temp1 >>= 1;
		}
		
    }     
	return crc8_result;
}

/Jesper
http://www.yampp.com
The quick black AVR jumped over the lazy PIC.
What boots up, must come down.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

really, thanks a lot!!!