This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28069: VCU unit (CRC instruction)

Part Number: TMS320F28069
Other Parts Discussed in Thread: C2000WARE, CONTROLSUITE, TEST2

Tool/software: Code Composer Studio

Hello all,

I'm trying to implement crc calculation using VCU of F28069. I refer the instruction sets that have mentioned  in the following documents.

http://www.ti.com/lit/ug/spruii0a/spruii0a.pdf   ----section 4.5

http://www.ti.com/lit/ug/spruhs1c/spruhs1c.pdf ----section 3.6.4

Then I made a assembly file with the instruction set, I have attached it with named as crc_code.asm .

also I made a struct in main file, like

"

typedef struct

{

Uint32 *CRCResult;  //  Addresswhereresultshouldbe stored

Uint16 *CRCData;//  Startof data

Uint16 CRCLen;//  Lengthof datain bytes

}CRC_CALC;

CRC_CALC mycrc;

Uint16 CRC16P1(CRC_CALC *crc_reg);

"

But there were some compilation errors.

Would you please kindly help? Thanks!

Best Regards,

Would you please kindly help? Thanks!

Best Regards,

  • spruii0a is for F2838x which contain the VCRC, F2806x contains the VCU-I so you want to refer to spruhs1c chapter 3.

    Did you mean to attach crc_code.asm? It appears you didn't.

    Also, why did you create an .asm file. Did you not try to leverage the existing library C callable assembly functions. Did you look at them? (the library and the examples). The examples are built for F2837x but should be easily portable to F2806x.

    C:\ti\c2000\C2000Ware_3_01_00_00\libraries\dsp\VCU\c28

    Also, you can refer to controlSUITE - controlSUITE\libs\dsp\VCU\v110\examples_ccsv4 . These are older, but match your device.

    Finally, you didn't let me know what compilation errors.

    Thanks,

    Sira

  • Thanks Sira,

    I forgot to mention about the errors, Here are the errors,

    Description    Resource    Path    Location    Type
    [E0003] Illegal indirect memaddr specification    crc_code.asm    /c2000_spi_test2    line 21    C/C++ Problem
    Description    Resource    Path    Location    Type
    [E0003] Syntax error - Operand 2    crc_code.asm    /c2000_spi_test2    line 22    C/C++ Problem
    Description    Resource    Path    Location    Type
    [E0004] Illegal operand combination    crc_code.asm    /c2000_spi_test2    line 21    C/C++ Problem
    Description    Resource    Path    Location    Type
    [E0004] Illegal operand combination    crc_code.asm    /c2000_spi_test2    line 22    C/C++ Problem
    Description    Resource    Path    Location    Type
    gmake: *** [crc_code.obj] Error 1    c2000_spi_test2             C/C++ Problem
    Description    Resource    Path    Location    Type
    gmake: Target 'all' not remade because of errors.    c2000_spi_test2             C/C++ Problem
    c2000_spi_test2.rar

    I'll attached the code here,

    thank you!

  • Harshana,

    The errors occurs with these two lines

    MOVL XAR7, *_+XAR4[0]; XAR7= &CRCResult
    MOV32 *+XAR7[0], VCRC; Storetheresult

    The changes I made that build without errors are shown below:

    MOVL XAR7, *+XAR4[0]; XAR7= &CRCResult
    VMOV32 *+XAR7[0], VCRC; Storetheresult

    Thanks,

    Sira

  • hi Sira,

    Is the crc unit of TMS320F28069 calculate according to CRC16-CCITT, when using use 16bit polynomial as 0x1021?

    Thank you,

    Regards,

    Harshana

  • Harshana,

    Correct. Refer to spracr3 for some details.

    Thanks,

    Sira

  • Sira,

    Should I feed 16Bit or 8Bit Values to "CRCData" array which I mention above?

    I passed a value 0xA to CRCData , and set the data length as 1. then I read the result. It should be 0x40BA. But I get different value 0xCD5F.

    Here the code attached.5187.c2000_spi_test2.rar

    Thank you for the help.

  • The VCRC16P1H_1 and VCRC16P1L_1 instructions operate on Bytes, but the C28x CPU does not have byte addressing, so you will be dealing with 16-bit words. The underlying assembly code will need to appropriately handle this.

    Our examples illustrate this quite extensively. Please look at them. Unfortunately, I cannot debug your code for you.

    Thanks,

    Sira

  • Thank You sira,

    But I didn't figure out it,

    can you say whether I'm correct or wrong when I use the mycrc struct, and data length ?

    Also I tried to move 0xFFFF to VCRC register, using "VMOV32 VCRC, mem32". But there is an error,

    "Description    Resource    Path    Location    Type
    [E0004] Illegal operand combination    crc_code.asm    /c2000_spi_test2    line 8    C/C++ Problem
    [E0004] Not expecting immediate value - Operand 2    crc_code.asm    /c2000_spi_test2    line 8    C/C++ Problem
    gmake: *** [crc_code.obj] Error 1    c2000_spi_test2             C/C++ Problem
    gmake: Target 'all' not remade because of errors.    c2000_spi_test2             C/C++ Problem"

    Thank you!

  • Harshana,

    mem32 has to be a memory location, it can't be an immediate value.

    This is the CRC structure our library uses.

    typedef struct _CRC_Obj_{
    uint32_t seedValue; //!< Initial value of the CRC calculation
    uint16_t nMsgBytes; //!< the number of bytes in the message buffer
    CRC_parity_e parity; //!< start the CRC from the low byte (CRC_parity_even) or high byte (CRC_parity_odd) of the first word (16-bit)
    uint32_t crcResult; //!< the calculated CRC
    void *pMsgBuffer; //!< Pointer to the message buffer
    void *pCrcTable; //!< Pointer to the CRC lookup table
    void (*init)(void *); //!< Function pointer to CRC initialization routine
    void (*run)(void *); //!< Function pointer to CRC computation routine
    }CRC_Obj;

    And this is how it is initialized.

    // Step 2: Initialize the CRC object
    CRC.seedValue = INIT_CRC16;
    CRC.nMsgBytes = NBYTES;
    CRC.parity = CRC_parity_even;
    CRC.crcResult = 0;
    CRC.pMsgBuffer = (uint16_t *)&testInput[0];
    CRC.pCrcTable = (uint16_t *)&crc16P1Table[0];
    CRC.init = (void (*)(void *))CRC_init16Bit;
    CRC.run = (void (*)(void *))CRC_run16BitTableLookupC;

    And this is the test Input, where NWORDS = NBYTES/2

    static const uint16_t testInput[NWORDS] = {
    0x4001, 0x8002, 0xC003, 0x0004, 0x4005, 0x8006, 0xC007, 0x0008,
    0x4009, 0x800A, 0xC00B, 0x000C, 0x400D, 0x800E, 0xC00F, 0x0010,
    0x4011, 0x8012, 0xC013, 0x0014, 0x4015, 0x8016, 0xC017, 0x0018,
    0x4019, 0x801A, 0xC01B, 0x001C, 0x401D, 0x801E, 0xC01F, 0x0020,
    0x4021, 0x8022, 0xC023, 0x0024, 0x4025, 0x8026, 0xC027, 0x0028,
    0x4029, 0x802A, 0xC02B, 0x002C, 0x402D, 0x802E, 0xC02F, 0x0030,
    0x4031, 0x8032, 0xC033, 0x0034, 0x4035, 0x8036, 0xC037, 0x0038,
    0x4039, 0x803A, 0xC03B, 0x003C, 0x403D, 0x803E, 0xC03F, 0x0040,
    };

    And note that CRC_parity_even means that CRC computation starts with the lower byte of the word i.e. in the above table, the order of data passed into the CRC computation routine will be 0x01, 0x40, 0x02, 0x80, 0x03, 0xC0, 0x04, 0x00, 0x05, 0x40, ....etc.

    If the parity is CRC_parity_odd then CRC computation will start with the high byte of the word i.e. the above table, the order of data passed into the CRC computation routine will be 0x40, 0x01, 0x80, 0x02, 0xC0, 0x03, 0x00, 0x04, 0x40, 0x05, ...etc.

    Thanks,

    Sira