hallo,
I would like to use the CRC instructions to calculate the CRC of a packet being sent through SCI.
in the documentation there are some examples, such as:
typedef struct {
uint32_t *CRCResult; // Address where result should be stored
uint16_t *CRCData; // Start of data
uint16_t CRCLen; // Length of data in bytes
}CRC_CALC;
CRC_CALC mycrc;
...
CRC16P1(&mycrc);
...
; -------------------
; Calculate the CRC of a block of data
; This function assumes the block is a multiple of 2 16-bit words
;
.global _CRC16P1
_CRC16P1
VCRCCLR ; Clear the result register
MOV AL, *+XAR4[4] ; AL = CRCLen
ASR AL, 2 ; AL = CRCLen/4
SUBB AL, #1 ; AL = CRCLen/4 - 1
MOVL XAR7, *+XAR4[2] ; XAR7 = &CRCData
.align 2
NOP ; Align RPTB to an odd address
RPTB _CRC16P1_done, AL ; Execute block of code AL + 1 times
VCRC16P1L_1 *XAR7 ; Calculate CRC for 4 bytes
VCRC16P1H_1 *XAR7++ ; ...
VCRC16P1L_1 *XAR7 ; ...
VCRC16P1H_1 *XAR7++ ; ...
_CRC16P1_done
MOVL XAR7, *_+XAR4[0] ; XAR7 = &CRCResult
MOV32 *+XAR7[0], VCRC ; Store the result
LRETR ; return to caller
after reading the documentation I still have some questions:
1. I need to initialize mycrc struct with my vector of bytes address and the length. this is trivial. true ?
2. as I understand the VCU works parallel to the CPU. do I need to wait for the result to be ready (VCRC register) ? I didn't see any flags indicating the result is ready... or the call to one of the CRC functions will be done when the result is ready ?
3. why is it written "this function assumes the block is a multiple of 2 16-bit words" ?
4. does the CRClen field in the struct is the length in bytes or words ?
5. if you could post a simple example showing how to calculate the CRC of a given vector of Uint16 will be great.
thanks
Ari.