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.

[参考译文] 编译器/TMS320F28375D:使用 Driverlib 通过 CLA 访问硬件寄存器

Guru**** 2425270 points


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

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/720225/compiler-tms320f28375d-accessing-hw-registers-with-cla-using-driverlib

器件型号:TMS320F28375D

工具/软件:TI C/C++编译器

大家好、  

从 CLA 访问硬件寄存器的干净方法是什么? 使用 HWREG 宏时、编译器会抛出"无效类型转换"警告。

使用它是否安全?

#define HWREG_CLA (x)   (*(volatile uint32_t *)((uint16_t)(x))))

这修复了编译器错误、因为 CLA 具有16位地址空间(和指针)。

此致

福尔克

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

    这很好。 在这条语句中、您要将地址转换为16位(良好)、然后取消引用它以进行32位访问(良好)。 如果是16位寄存器、则可以使用

    #define HWREG_CLA (x) (*((volatile uint16_t *)((uint16_t)(x))))

    希望这对您有所帮助!
    SAL