CRC-32 for MPC5676R correction required

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CRC-32 for MPC5676R correction required

524 Views
dineshs
Contributor I

uint8_t index = 0;
uint32_t calculatedCRC = 0;

CRC.CNTX[3].CRC_CFG.B.POLYG = 1; /* To select CRC32 polynomial */
CRC.CNTX[3].CRC_CFG.B.SWAP = 1; /* To select swap in output CRC */
CRC.CNTX[3].CRC_CFG.B.INV = 1; /* inversion applied on CRC output */
CRC.CNTX[3].CRC_CSTAT.R = 0xFFFFFFFF; /*Seed Value*/


for(index= 0; index<inputdata_Length; index++)
{
__stwbrx( inputdata[index],0, &CRC_Engine->CNTX[3].CRC_INP.R );
}
calculatedCRC = CRC_Engine->CNTX[CONTEXT3].CRC_OUTP.R;

can some body help to replace __stwbrx( dataStartAddress[index],0, &CRC_Engine->CNTX[CONTEXT3].CRC_INP.R ); to equivalent C code ,as it is inline assembly code that violates the coding standard or pls share entire in assembly code power pc architecture
__stwbrx( dataStartAddress[index],0, &CRC_Engine->CNTX[CONTEXT3].CRC_INP.R );
is used to handled errata issue in MPC5676R
errta: input value get swapped in CRC_Engine->CNTX[3].CRC_INP.R
if input is 0x1234 to CRC_INP actually feed as 0x3412 to CRC_INP

0 Kudos
1 Reply

392 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

if you need to swap bytes in 32bit word, you can use simple C code like this:

unsigned int input_data = 0x12345678;

unsigned int swapped_data;

swapped_data = ((input_data>>24)&0xff) | ((input_data<<8)&0xff0000) | ((input_data>>8)&0xff00) | ((input_data<<24)&0xff000000);

Regards,

Lukas

0 Kudos