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.

[参考译文] TMS570LS1224:gioSetDirection 使用

Guru**** 2540720 points


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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/999680/tms570ls1224-giosetdirection-use

器件型号:TMS570LS1224

在上一个问题中、我被告知添加 gioSetDirection (gioPORTA、0xFE);  在我的代码中、我 将 GIOA[0]设置为一个输入、并且它运行良好。

但是、如何将多个引脚配置为输入?

假设我也要读取 GIOA[2] 和 GIOA[3] (前面对代码进行了注释)。  

gioSetDirection (gioPORTA、0xFE);
gioSetBit (gioPORTA、1U、1);
a=gioGetBit (gioPORTA、0U);
//B=gioGetBit (gioPORTA、2U);
//C=gioGetBit (gioPORTA、3U);

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

    gioSetDirecton()在 gio.c 中定义:

    TRM 中描述了 DIR 寄存器:25.5.11节

    GIODIR[A]的位0用于 GIOA[0]、位1用于 GIOA[1]、……

    向某个位写入1是为了将相应的引脚配置为输出、但向某个位写入0是为了将该引脚配置为输入。

    DIR[7:0]= 0xAA=B101010_1010将 GIOA[0]、GIOA[2]、GIOA[4]和 GIOA[6]配置为输入、将 GIOA[1]、GIOA[3]、GIOA[5]和 GIOA[7]配置为输出