gpt4 book ai didi

c - MSP430 LED 根本不闪烁

转载 作者:行者123 更新时间:2023-11-30 16:39:51 24 4
gpt4 key购买 nike

我一直在尝试打开 MSP430G2553 上的 LED,但它不起作用。我尝试过 TI 的代码示例、预生成的代码 Composer Studio LED 闪烁项目,甚至是过去在 MSP430 上运行的代码。它们似乎都不起作用。可能是什么问题呢?会不会是硬件有问题?这是我的代码:

#include  <msp430.h>

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction

for (;;)
{
volatile unsigned int i;
volatile unsigned int j;

P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR

i = 25000; // Delay
while(i--) {
j = 2;
while(j--);
}
}
}

最佳答案

我在使用 MSP430FR5994 开发板时遇到了一个问题,即在闪烁示例中 LED 不会亮起,但在“开箱即用体验”项目中它们会亮起。比较代码,我确定差异在于 pmm.c 中的这一行:

//For FRAM devices, at start up, the GPO power-on default
//high-impedance mode needs to be disabled to activate previously
//configured port settings. This can be done by clearing the LOCKLPM5
//bit in PM5CTL0 register
PM5CTL0 &= ~LOCKLPM5;

将其放在 main() 的顶部似乎可以解决任何问题,并且 LED 的行为符合预期。

关于c - MSP430 LED 根本不闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46918436/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com