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/MSP430F2252:GPIO 引脚切换 LED

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/762186/ccs-msp430f2252-gpio-pin-toggle-led

器件型号:MSP430F2252

工具/软件:Code Composer Studio

#include

volatile unsigned int i;// volatile 以阻止优化

int main (空)

WDTCTL = WDTPW + WDTHOLD;//停止看门狗计时器
P2DIR |= 0xFF;//将端口2中的所有引脚设置为输出方向

while (1)

P2OUT ^= 0xFF;//使用异或切换所有端口2引脚

I = 50000;//延迟
执行(i -);
while (i!= 0);

这是我写入的用于切换端口2中所有 GPIO 引脚的代码、但结果是 P2.6和 P2.7引脚未切换、所有其他引脚被切换。 我对端口1、端口3和端口4引脚尝试的相同操作正常。 我能不能知道为什么它不能仅用于这两个特定的引脚。(在我的设计中、P2.7引脚用于启用 RS485数据)。请在这里提供帮助。

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

    P2.6/P2.7的 P2SEL 位在启动时被置位、以便与一个晶振一起使用。 [参考用户指南(SLAU144J)表8-2.] 尝试添加:
    根据 SLAS504G 表29/30、>P2SEL &=~(BIT6|BIT7);// P2.6-7作为 GPIO

    [编辑:固定措辞]

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

    非常感谢 Bruce、现在工作正常。