AnsweredAssumed Answered

CRC_8 for Kinetis K60?

Question asked by Dermot Mullooly on Feb 11, 2012
Latest reply on Jun 25, 2014 by EARL GOODRICH

Hi,

 

I am trying to implement  SAE J1850 crc_8 using CRC Module in K60.

 

The CRC Module generates crc_16/32-bit codes but crc_8 is required.

I'm thinking this should not be a problem but am not having any success

getting expected output.

 

Input data:                                                            0xFFFFFFFF

Expected output (complemented):                 0x0074

Actual output (complemented):                       0x30FF

 

I do not have alot of experience with CRC and maybe am interpreting the

calculation incorrectly or need an extra logical to perform on the CRC output.

 

Here is the complete code; any of you guys with experience using CRC got any suggestions?

 

 

void Main_task(uint_32 initial_data)
{
    
        uint_32 result=0;
        
        /* Enable CRC module */
        SIM_SCGC6 |= SIM_SCGC6_CRC_MASK;
        
        /* Configure CRC_CTRL for 16-bit and complement read */
        CRC_BASE_PTR->CTRL    =     CRC_CTRL_FXOR_MASK;
        CRC_BASE_PTR->CTRL    &=     ~CRC_CTRL_TCRC_MASK;
        
        /* Write SAEJ1850 polynomial to CRC_GPOLY register - SAE J1850 CRC: X8 + X4 + X3 + X2 + 1 */
        CRC_BASE_PTR->GPOLY_ACCESS16BIT.GPOLYL    =    0x11D;
        
        /* Configure CRC_CTRL for seed */
        CRC_BASE_PTR->CTRL    |=     (CRC_CTRL_WAS_MASK);
        
        /* Seed CRC with all ones */
        //CRC_BASE_PTR->ACCESS16BIT.CRCH    =    0x0000;
        CRC_BASE_PTR->ACCESS16BIT.CRCL    =    0xFFFF;
        
        /* Clear seed bit to start writing data values */
        CRC_BASE_PTR->CTRL    &=     (~CRC_CTRL_WAS_MASK);
        
        /* Write data to CRC data register */    
        CRC_BASE_PTR->CRC                =    0xFFFFFFFF;        /* Data */
        CRC_BASE_PTR->ACCESS8BIT.CRCLU     =    0x00;;            /* Zeros padding */
        
        /* Output complement of remainder */
        printf("CRC byte:\t%X   \n", (uint_16) CRC_BASE_PTR->ACCESS16BIT.CRCL);
        
        /* Output remainder */
        CRC_BASE_PTR->CTRL    &=     (~CRC_CTRL_FXOR_MASK);
        printf("CRC byte:\t%X   \n", (uint_16) CRC_BASE_PTR->ACCESS16BIT.CRCL);
        
        //_mqx_exit(0);
}

Outcomes