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.

TMS320F28375S: SPI running in CLA reads wrong value

Part Number: TMS320F28375S
Other Parts Discussed in Thread: C2000WARE

Hi,

I am reading 5 bytes of data through SPI. Engineering data is created from these bytes as:

Data1 = (byte2 << 8) | byte3;

Data2 = (byte4 << 8) | byte5;

When this SPI code runs on CPU1, it reads the data correctly.

But when I move this code to CLA, the Data1 is read correctly, but Data2 is exactly half of what it reads when the code is in SPI (checked for multiple values). Am I missing something here?

I have moved it back-forth between CPU1 and CLA, and the problem is consistent.

SPI clock is 5MHz, Data1 is read correctly, so I assume that means SPI and CLA is configured correctly. I have checked that CLA reads and writes to SPI registers are fine.

CPU is the owner (GPxCSEL register) for the pins used as SCLK, SDI, SDO and Chip Select. Can that be a problem?

CLA task is triggered by EPWM interrupt.

Please let me know if any more information is required.

Thank you.

  • Data2 is exactly half of what it reads when the code is in SPI

    Correction: Data2 is exactly half of what it reads when the code runs in CPU1.

  • Hi Gobind,

    Are you using bitfield code on CLA?

    We recently found an issue with bitfield code on TMS320F28375S device. The definition of Uint16/32 is incorrect for CLA.

    In case you are using bitfields or use UInt16/32 types, can try the following workaround and check if the issue is resolved. This change will be rolled out in the upcoming C2000ware release.

    In <device>_device.h file:

    typedef int int16;
    typedef long int32;
    typedef long long int64;
    typedef unsigned int Uint16;
    typedef unsigned long Uint32;
    typedef unsigned long long Uint64;
    typedef float float32;
    typedef long double float64;
    
    

    This should be replaced with :

    #ifdef __TMS320C28XX_CLA__
    typedef short                                   int16;
    typedef long                                    int32;
    typedef unsigned char                           Uint8;
    typedef unsigned short                          Uint16;
    typedef unsigned long                           Uint32;
    typedef float                                   float32;
    typedef long double                             float64;
    typedef struct { Uint32 low32; Uint32 high32; } Uint64;
    typedef struct { int32  low32; int32  high32; } int64;
    #else // __TMS320C28XX__
    typedef int                                     int16;
    typedef long                                    int32;
    typedef long long                               int64;
    typedef unsigned int                            Uint16;
    typedef unsigned long                           Uint32;
    typedef unsigned long long                      Uint64;
    typedef float                                   float32;
    typedef long double                             float64;
    #endif //__TMS320C28XX_CLA__
    

    Regards,

    Veena

  • Hi Veena,

    I updated the device.h file with the above code, but that did not make any difference.

    I tried reading the data at higher/lower SPI baud rate, same results.

    I tried reading in a different byte order, like b1,b2,b3,b4,b5 in order of b3,b4,b1,b2,b5 or b2,b1,b4,b3,b5. In any order, b1, b2 and b3 are read fine, but ((b4<<8) | b5) is always half of what it should be.

    The moment I move this code to main CPU, everything works very well.

  • Hi Veena, 

    The issue is resolved, there was a problem with the configuration of the other device communicating with microcontroller.

    Thank you for the reply.