简体   繁体   English

复位后 MSP430 ACLK 问题

[英]MSP430 ACLK problems after reset

I have an MSP-EXP430G2ET launchboard which has msp430g2553 microcontroller.我有一个带有 msp430g2553 微控制器的 MSP-EXP430G2ET 启动板。 I bought it for my embedded systems course.我为我的嵌入式系统课程购买了它。

Lately we learned to use timers and the last lab work was using the watchdog timer in time interval mode.最近我们学会了使用定时器,最后的实验工作是在时间间隔模式下使用看门狗定时器。 But while doing that I figured out my ACLK was not working properly.但是在这样做时,我发现我的 ACLK 工作不正常。 I check the datasheet and guide for the board and It has ACLK if I'm not mistaken.我检查了电路板的数据表和指南,如果我没记错的话,它有 ACLK。 By the way when I touch the pins of the board LED blinks at different frequencies.顺便说一下,当我触摸板的引脚时,LED 以不同的频率闪烁。

This is the code that I used for the watchdog timer to light a LED with a period.这是我用于看门狗定时器以一个周期点亮 LED 的代码。

#include <msp430.h>

int main(void)
{
    WDTCTL = WDTPW | WDTCNTCL | WDTIS0 | WDTSSEL | WDTTMSEL;// config watchdog timer aclk 1ms

    P1DIR |= BIT0 | BIT6; // P1.0 and P1.6 is configured as output
    P1OUT = ~BIT0 | ~BIT6; // Led P1.0 and P1.6 are turned off

    while (1){
        if (IFG1&BIT0 != 0){
            P1OUT ^= BIT0 | BIT6;
            IFG1 &= ~WDTIFG;
        }
    }
}

This code does not work.此代码不起作用。 LED does not light up. LED 不亮。

From the code snippet nothing looks outrageously wrong so without a device at my disposal I will take 4 stabs in the dark.从代码片段来看,没有什么是大错特错的,所以如果没有我可以使用的设备,我会在黑暗中刺伤 4 次。

  1. Make sure the correct msp430 is chosen in your project.确保在您的项目中选择了正确的 msp430。 msp430.h can lead to any of the msp430 headers depending on a define, a wrong one can mess with your project. msp430.h 可以根据定义导致任何 msp430 标头,错误的标头可能会干扰您的项目。
  2. I would advise using the WDT_ADLY_XXX defines to set WDT_CTL.我建议使用 WDT_ADLY_XXX 定义来设置 WDT_CTL。 They're more legible.它们更易读。
  3. It is advised that you place the watchdog in hold (WDTPW|WDTHOLD) before changing it's settings.建议您在更改其设置之前将看门狗置于保持状态(WDTPW|WDTHOLD) It may be freaking out and resetting your device while you attempt to set it up.当您尝试设置它时,它可能会吓坏并重置您的设备。
  4. P1OUT = ~BIT0|~BIT6 has wrong operator prescience. P1OUT = ~BIT0|~BIT6有错误的操作员预知。 Each NOT is done before the OR.每个 NOT 都在 OR 之前完成。 This does not have the same effect as ~(BIT0|BIT6) which ORs them together and then NOTs.这与~(BIT0|BIT6)效果不同,后者将它们进行 OR ~(BIT0|BIT6) ,然后进行非运算。

I have an MSP-EXP430G2ET launchboard which has msp430g2553 microcontroller.我有一个具有msp430g2553微控制器的MSP-EXP430G2ET启动板。 I bought it for my embedded systems course.我在嵌入式系统课程中购买了它。

Lately we learned to use timers and the last lab work was using the watchdog timer in time interval mode.最近,我们学会了使用计时器,最后的实验工作是在时间间隔模式下使用看门狗计时器。 But while doing that I figured out my ACLK was not working properly.但是在这样做的时候,我发现我的ACLK不能正常工作。 I check the datasheet and guide for the board and It has ACLK if I'm not mistaken.我检查了数据手册并为开发板提供了指南,如果我没有记错的话,它具有ACLK。 By the way when I touch the pins of the board LED blinks at different frequencies.顺便说一下,当我触摸电路板的引脚时,LED会以不同的频率闪烁。

This is the code that I used for the watchdog timer to light a LED with a period.这是我用于看门狗定时器的代码,用于以一定的时间点亮LED。

#include <msp430.h>

int main(void)
{
    WDTCTL = WDTPW | WDTCNTCL | WDTIS0 | WDTSSEL | WDTTMSEL;// config watchdog timer aclk 1ms

    P1DIR |= BIT0 | BIT6; // P1.0 and P1.6 is configured as output
    P1OUT = ~BIT0 | ~BIT6; // Led P1.0 and P1.6 are turned off

    while (1){
        if (IFG1&BIT0 != 0){
            P1OUT ^= BIT0 | BIT6;
            IFG1 &= ~WDTIFG;
        }
    }
}

This code does not work.此代码不起作用。 LED does not light up. LED不亮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM