Jump to content
Matjaz

WDTCTL not working with MSP432?

Recommended Posts

Hi, guys,

 

I cannot seem to be able to stop the watchdog on the Energia + MSP432 combo.

(MSP-EXP432P401R Rev 1.0 + Energia 0101E0016 on Win7-64bit)

// My minimal code buzzes the red led at 2MHz:
 #include "msp432p401r.h"

 void setup() {
   WDTCTL = WDTPW | WDTHOLD;        // Stop WDT
   pinMode(RED_LED, OUTPUT);        // configure pin
 }

 void loop() {
   while (1) {
     P2OUT ^= 0x01; P2OUT ^= 0x01;  // flip pin twice
   };
 }

The 2MHz output signal freezes for 12us in either "1" or "0" state every 1ms.

WDTHOLD bit does not help (in fact, any WDTCTL actions seem to be ignored).

 

Cross testing done:

- TI CCS Cloud correctly builds C code for same MSP-EXP432 board (i.e. WDTCTL line does make a difference there)

- Same Energia IDE correctly builds equivalent code for a MSP-EXP430G2 /2452 board (WDTCTL line again does make a difference).

 

 

(In addition, if it matters: pure C compiling in Energia as per https://bennthomsen.wordpress.com/engineering-toolbox/ti-msp430-launchpad/using-energia-to-code-in-c/ does not work for the 432 (compiles and flashes OK, but board remains dead) while it does work for a plain ol' 430 board.)

 

 

There, hope there's enough data.

Any ideas?

Thanks a lot! Matjaz

Share this post


Link to post
Share on other sites

(I had an answer here which I thought was helpful, but I was mistaken, so ...

I'll look around to see how to delete my comment.

Sorry for messing up your topic.)

 

In the meantime, this is the driverlib routine, which suggests you're doing the right thing.

void WDT_A_holdTimer(void)
{
    //Set Hold bit
    uint8_t newWDTStatus = (WDT_A->rCTL.r | WDTHOLD);
    WDT_A->rCTL.r = WDTPW + newWDTStatus;
}

Share this post


Link to post
Share on other sites
The 2MHz output signal freezes for 12us in either "1" or "0" state every 1ms.

WDTHOLD bit does not help (in fact, any WDTCTL actions seem to be ignored).

 

Are you sure the pauses are being caused by the watchdog?

 

Perhaps try toggling another LED a few times before the while(1) in your loop function. That will confirm whether the code is resetting and running from the start or not.

Share this post


Link to post
Share on other sites

No prob @@mgh, thanks anyway.

 

@@tripwire, I think it's the watchdog because in one of my my two cross checks (with same board but another compiler) I can switch this behavior on and off by (un)commenting the WDTCTL line.

 

BTW, I did try a similar test that you suggest but with LED toggling in setup(). It did not show up during resets. How come the watchdog reset is not throwing me in the setup routine but rather into loop()?

 

cheers M

Share this post


Link to post
Share on other sites

...did as per @@tripwire suggestion now - fiddled the LED bit some just before the while(1):

 

I see it does not really restart (no difference in bit banging pattern). This leads me into thinking that the WDT does not reset the chip but rather that it calls some sort of Interrupt handling routine which does nothing and returns, simply losing the 12us each time.

 

I'm still kinda convinced it's really the WDT kicking in because in the test compiled in CCS this behavior depends exactly on the state of WDTHOLD bit.

 

cheers

Share this post


Link to post
Share on other sites

...

How come the watchdog reset is not throwing me in the setup routine but rather into loop()?

 

cheers M

setup() is a function called once during program start.

loop() is a function that equates to a big while() loop where everything within repeats ad infinitum.

 

So, you might get through setup() before WDT expires, but in loop() WDT can time out, particularly if you're trying to manage it outside of the Energia framework.

Share this post


Link to post
Share on other sites

Could it possibly be the MT mode of Energia when used with the MSP432 is a contributor?  Perhaps @@Rei Vilo   could shed more light on this....

 

I think it might be. There could be some system task that wakes up every millisecond causing the small delay.

Share this post


Link to post
Share on other sites

setup() is a function called once during program start.

loop() is a function that equates to a big while() loop where everything within repeats ad infinitum.

 

So, you might get through setup() before WDT expires, but in loop() WDT can time out, particularly if you're trying to manage it outside of the Energia framework.

Yup, I understand that.. I wasn't wondering where it occurs but rather where I'll be thrown back at after it does. One would think that at start of code, right...? That's the beast's purpose...

Share this post


Link to post
Share on other sites

The multitasking mode is a temptingly possible culprit, but it is really funny that it behaves _exactly_ as the watchdog reset does. (I know from the tests compiled via CCS where I do have a working control over it).

 

Ok, let's assume this is not WDT kicking in, but something else with a timing pattern that is, by chance, exactly the same. Then, a version of code with WDT enabled and another one with WDT reset disabled, it should still make a difference: an extra delay would still appear when WDT enabled. Reductio ad absurdum.

 

So.. for the time being, I'm concluding this is a possible Energia feature.

I will speculate here: Energia disables WDT resets in a way that does not really block it (as CCS does) but rather calls an empty function which returns in a couple of microseconds?

 

thanks!

Matjaz

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...