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:在 CLA 中运行的 SPI 读取的值错误

Guru**** 2382060 points
Other Parts Discussed in Thread: TMS320F28375S, C2000WARE
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1029078/tms320f28375s-spi-running-in-cla-reads-wrong-value

器件型号:TMS320F28375S
主题中讨论的其他器件: C2000WARE

您好!

我正在通过 SPI 读取5个字节的数据。 工程数据通过这些字节创建、如下所示:

Data1 =(字节2 <<8)|字节3;

Data2 =(字节4 <<8)|字节5;

当该 SPI 代码在 CPU1上运行时、它会正确读取数据。

但是、当我将该代码移动到 CLA 时、Data1被正确读取、但 Data2恰好是代码位于 SPI 中时(检查多个值)所读取数据的一半。 我在这里缺少什么吗?

我已在 CPU1和 CLA 之间将其移回、问题始终如一。

SPI 时钟为5MHz、Data1被正确读取、因此我假设这意味着 SPI 和 CLA 被正确配置。 我已经检查了 CLA 对 SPI 寄存器的读取和写入是否正常。

CPU 是用作 SCLK、SDI、SDO 和芯片选择的引脚的所有者(GPxCSEL 寄存器)。 这会是个问题吗?

CLA 任务由 ePWM 中断触发。

如果需要更多信息、请告诉我。

谢谢你。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [引用 userid="448206" URL"~/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1029078/tms320f28375s-spi-running-in-cla-reads-wrong-value ]Data2恰好是代码位于 SPI 中时的一半

    更正:Data2恰好是代码在 CPU1中运行时读取内容的一半。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Gobind、

    您是否在 CLA 上使用位域代码?

    我们最近发现 TMS320F28375S 器件上的位域代码存在问题。  对于 CLA、UINT16/32的定义不正确。

    如果您使用的是位字段或使用 uint16/32类型、可以尝试以下解决方法并检查 问题是否已解决。 此更改将在即将推出的 C2000ware 版本中推出。

    在中 _device.h 文件:

    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;
    
    

    应将其替换为:

    #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__
    

    此致、

    Veena

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Veena、

    我使用上述代码更新了 device.h 文件、但这没有任何区别。

    我尝试以更高/更低的 SPI 波特率读取数据、结果相同。

    我尝试以不同的字节顺序读取、如 B1、B2、B3、b4、B5、顺序为 B3、b4、b1、b2、b5或 b2、b1、b4、b3、b5。 按任何顺序、B1、B2和 B3被读取为正常、但((b4<8)| B5)始终是它应该为的一半。

    当我把这个代码移动到主 CPU 时、一切都运行得很好。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Veena、  

    此问题已解决、与微控制器通信的另一个器件的配置存在问题。

    感谢你的答复。