Ja, hat sich erledigt. Es ist so, dass das Ergebnis in crc1:crc0
steht...
Die Routine vom ELM-Chan unten, die ich zuerst verwendete liefert ein
andres Ergebnis und braucht mehr Takte, obwohl auch CCITT dabeisteht.
Vielleicht hab ich sie auch nur falsch angewendet, aber es passt jetzt.
1 | ;-----------------------------------------------;
|
2 | ; Generate/Check CRC(-CCITT)
|
3 | ;
|
4 | ; Register Variables
|
5 | ; Call: crc[1:0] = CRC working register
|
6 | ; src = Source data to be checked
|
7 | ; lc,tmp[1:0] = <don't care> (high register must be allocated)
|
8 | ;
|
9 | ; Result:crc[1:0] = Updated
|
10 | ; src = 0
|
11 | ; lc,tmp[1:0] = broken
|
12 | ;
|
13 | ; Size = 12 words
|
14 | ; Clock = 66..74 cycles (+ret)
|
15 | ; Stack = 0 byte
|
16 | ;
|
17 | ; To generate a CRC:
|
18 | ; 1. Clear CRC working register.
|
19 | ; 2. Process all data bytes in the block.
|
20 | ; 3. Process two bytes of zero.
|
21 | ; 4. The CRC will be found in the working register.
|
22 | ; 5. Append crc1 and crc0 to the block data.
|
23 | ;
|
24 | ; To check block:
|
25 | ; 1. Clear CRC working register.
|
26 | ; 2. Process all data bytes in the block and following CRCs.
|
27 | ; 3. The block is correct if the working register is zero.
|
28 |
|
29 |
|
30 | crc:
|
31 | ldi tmp1,0b00010000 ;CRC-CCITT (2^16+2^12+2^5+2^0)
|
32 | ldi tmp0,0b00100001 ;/
|
33 | ldi lc,8 ; Loop count = 8
|
34 | lsl src ;--- bit processing loop
|
35 | rol crc0 ;Shift-in a bit into working reg.
|
36 | rol crc1 ;/
|
37 | brcc PC+3 ;If pushed out a bit "1", divide it.
|
38 | eor crc1,tmp1 ;
|
39 | eor crc0,tmp0 ;/
|
40 | dec lc ;Repeat until end of loop
|
41 | brne PC-7 ;/
|
42 | ret
|
Ok, sie braucht dafür weniger FLASH
Gibt es da einen Unterschied zwischen den beiden, oder sonstige Vor- und
Nachteile?
MfG
Stefan