Pumpkin, Inc.

Pumpkin User Forums

Watchdog Timer and No Eligible Tasks?

For issues specific to TI's MSP430 line of ultra-low-power microcontrollers, including compilers (e.g. Quadravox AQ430), IDEs (e.g. IAR Embedded Workbench) and development tools (e.g. TI MSP-FET430 Flash Emulation Tool).

Watchdog Timer and No Eligible Tasks?

Postby AaronInSpace » Wed Oct 05, 2011 1:18 pm

I've got a MSP430 and Salvo and started attempting to enable the WDT today on a project near completion. I found I get WDT resets in the first call to OS_Delay(). This first call is in the only task created at the time. Should that be a problem?

Perhaps I need to add OSClrWDTHook() to the OSIdlingHook?

Background info:
uC = MSP430F1612 in CSK
IDE = RA v.2
Number of tasks = 1 at time of crash, more created later on
LPM1 enabled in OSIdlingHook
100 Hz Timer A OSTimer (32KHz crystal as source with 328 as timer interval)
LPM off in TimerA interrupt
AaronInSpace
 
Posts: 8
Joined: Wed Jul 06, 2011 2:04 pm

Re: Watchdog Timer and No Eligible Tasks?

Postby aek » Thu Oct 06, 2011 9:15 am

Turn off your WDT.

I seriously doubt your WDT reset has anyting to to with OS_Delay() ... rather, the timeout is happening at a normal timeout period, and you happen to be in OS_Delay() when it happens.

Until your application is much further along -- a never when debugging -- it's best to keep the WDT disabled.
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Watchdog Timer and No Eligible Tasks?

Postby aek » Thu Oct 06, 2011 11:09 am

Until your application is much further along -- and never when debugging -- it's best to keep the WDT disabled.
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Watchdog Timer and No Eligible Tasks?

Postby AaronInSpace » Thu Oct 06, 2011 3:20 pm

The project is otherwise near completion. Adding the WDT was, as you suggested, held off until the end of development.

I got some assistance this afternoon to dig into this issue and found some interesting things. If I comment out the line that does OS_Delay() and instead replace it with my milliDelay() function which uses the intrinsic delay cycles function of MSP430s, my code runs along. It continues into the point where there are now a handful of tasks. All of these tasks work on an OS_Delay cycle where they are inactive 99% of the time or else are stuck waiting on a binary semaphore that I never activate (by means of not transmitting to the device). The program works fine and doesn't hickup.

So then I went back to using OS_Delay instead of the milliDelay in the first section of code I have (to remind you: this is the start of code where I have only 1 task created at the time of the OS_Delay in it). Then I added some code to the Salvo function in salvohook_wdt_RA430_CLRWDT.c that toggles a spare pin I have. Then, I took another free pin and drove it high right where the code activates the WDT. I then pulled the line low right before OS_Delay is called. I hooked it up to an oscilloscope and when my second line went low, the WDT pin stopped toggling. In other words, OS_Delay stopped the calling of the function which clears the WDT.

To verify this, I then moved the pulling of the second line low from just before the call to OS_Delay to just after. What I saw was that the WDT pin stopped toggling (presumably at the point that OS_Delay was called) and the pulling low of the OS_Delay line never happened.

So it would seem somehow OS_Delay is stopping the WDT. I also want to emphasize that there was only a problem with this when just one task is running and calls OS_Delay. When more than one task is running OS_Delay is fine. Thanks for your time Andy!
AaronInSpace
 
Posts: 8
Joined: Wed Jul 06, 2011 2:04 pm

Re: Watchdog Timer and No Eligible Tasks?

Postby Andrew » Thu Oct 06, 2011 4:07 pm

There's no relationship between OS_Delay() and the watchdog timer, nor to the WDT hook.

Salvo doesn't touch the WDT at all. The (user) hook touches the WDT, and that hook is called from within the scheduler. A default library build has a default hook built into it, but this is overridden when the user hook is linked in.

I seem to recall that some MSP430's have ... wait for it ... a different WDT register address than others (!). In this case, any precompiled Salvo code that hits the WDT may be wrong (because it uses the "old" WDT register address).

If an errant pointer is misbehaving somewhere, then all bets are off.

Are you using Rowley? In that case, make sure that you have disabled the register allocation optimization as per http://pumpkininc.com/content/doc/manual/rm-ra430.pdf .

My guess is that you either have a mismatch of the salvocfg.h, or there is stack corruption going on due to a local var in a task or maybe a bad optimization, or there's something else fundamental to the wdt hook or the WDT itself.

The difference between your millidelay and OS_Delay(0 is that the former doesn't involve a context switch, and therefore doesn't have any chance of suffering due to stack corruption. Well, that and a trip through OS_Delay() will result in a trip through the scheduler.
Andrew
Site Admin
 
Posts: 68
Joined: Mon Nov 30, 2009 6:43 pm

Re: Watchdog Timer and No Eligible Tasks?

Postby AaronInSpace » Thu Oct 06, 2011 4:28 pm

Hi Andy,
Thanks for your response. I had overwritten the default WDT code as per your instructions. Actually you had provided code for Rowley on the MSP430 that was sufficient for resetting the WDT as far as me and my team can tell.

When you say that it is the user's code that that clears the WDT is that to say that I should be making my own calls to OSClrWDTHook from within TimerA or something such as that? I was under the impression that Salvo was clearing the WDT itself and therefore should do so during a Salvo delay.
AaronInSpace
 
Posts: 8
Joined: Wed Jul 06, 2011 2:04 pm

Re: Watchdog Timer and No Eligible Tasks?

Postby AaronInSpace » Thu Oct 06, 2011 4:34 pm

Sorry, I was on my way out the door for the week and wanted to make sure I replied while it was still fresh in memory and didn't respond fully. In response to some of your questions: Yes, I do have register allocation set to None. Also, here is my salvocfg.h file:
Code: Select all
#ifndef __salvocfg_h
#define __salvocfg_h

#include <msp430.h>

/*                                                          */
/*  Salvo Pro Libary build                                  */
/*                                                          */
#define OSUSE_LIBRARY            TRUE
#define OSLIBRARY_TYPE               OSL  // OSF for freeware build, OSL for Pro build
#define OSLIBRARY_CONFIG            OST  // OST allows for everything... events and delays
#define OSLIBRARY_VARIANT           OSA  // OSA variant allows for calling Salvo services in both foreground (interrupts) and background (normal code)
#define OSEVENTS                    5
#define OSEVENT_FLAGS               0
#define OSMESSAGE_QUEUES            0
#define OSTASKS                     7

#endif
AaronInSpace
 
Posts: 8
Joined: Wed Jul 06, 2011 2:04 pm

Re: Watchdog Timer and No Eligible Tasks?

Postby Andrew » Thu Oct 06, 2011 5:48 pm

AaronInSpace wrote:Hi Andy,
When you say that it is the user's code that that clears the WDT is that to say that I should be making my own calls to OSClrWDTHook from within TimerA or something such as that? I was under the impression that Salvo was clearing the WDT itself and therefore should do so during a Salvo delay.

Absolutely not (do not call OSClrWDTHook from other places).

It's the user code that clears the WDT because the hooks in Salvo 4 are user-specifiable hooks. That's the whole point of having hooks -- so that the user can change a fundamental part of the Salvo application's behavior, without modifying any Salvo core code. Yes, Salvo provides default (user) hooks, and they may be OK for some apps, but not for all.

Salvo calls the WDT hook -- a user function that has a default form as provided -- and that clears the WDT. This provides the user with a simple, single-point clearing of the WDT. Its is not a cure-all, nor is it infallible -- it's just something that can be used, or overriden (by changing the WDT hook).

One way to understand why this is true (that Salvo is not intimately tied to clearing the WDT) is that ANSI C does not provide a dedicated function to clear the WDT, and Salvo's core is highly compliant ... since all of the various targets that Salvo runs on have different ways of clearing the WDT (sometimes the assembler has a dedicated function, other times it's a register write, sometimes in multiple stages), this target-dependent function is pulled out of Salvo and moved to the (user) hooks.

The call to the WDT hook happens within OSSched(). Since OSSched() is called open-loop, it means that in your app, it's being called very frequently, much faster than the WDT interval.

There are no variants (see salvocfg.h) when using Salvo libraries for MSP430 ... I hope you are linking to a -t.hza or it.hza library, because that is what your salvocfg.h specifies.

Nothing that you have written suggests to me that there is something inherently wrong or right with the WDT clearing -- I think the problem is elsewhere, probably going in and out of LPM. Especially at startup with only one task running, there is very little going on -- Salvo manages the context switching of tasks, and delayed tasks enter the delay queue, and the timer ticks along, and OSSched() has nothing to do, therefore calls the WDT hook very rapidly. When a delay times out, that task will eventually run again, but it is independent of the clearing of the WDT, which happens once per OSSched() call, via the hook.

You also need to ensure that all ISRs that call Salvo services disable LPM on exit, otherwise you will have runtime problems ... but likely not what you describe here.

What happens if you turn off all LPM stuff?
Andrew
Site Admin
 
Posts: 68
Joined: Mon Nov 30, 2009 6:43 pm

Re: Watchdog Timer and No Eligible Tasks?

Postby Andrew » Thu Oct 06, 2011 5:56 pm

In fact, I think the problem is that you are in LPM.

Salvo's delays can be much longer than the WDT timeout period. The call to OSTimer() guarantees that -- if LPMs are suppressed at the end of the ISR correctly, so that the application wakes up from LPM, runs through the scheduler, and then finds itself in the idling hook again, where LPM is invoked -- any tasks affected by Salvo events (e.g. signaling, delays timing out, etc.) will be processed properly in tandem with LPM.

But, if the timer tick is long compared to the WDT period, or if there is something wrong with the timer waking the system up, then your WDT will time out early and cause a reset. Since you say this is happening with just a single task and not much else going on, AND you have some LPM stuff active, this leads me to believe that this is an LPM - WDT - timer interaction.

Note that the idling hook is invoked on a pass through OSSched() only if no tasks are eligible ... but the WDT hook is called every time.
Andrew
Site Admin
 
Posts: 68
Joined: Mon Nov 30, 2009 6:43 pm

Re: Watchdog Timer and No Eligible Tasks?

Postby AaronInSpace » Tue Oct 18, 2011 11:48 am

Sorry to take so long to respond; I haven't been working on this project for a little bit.

You nailed it! There does some to be an interaction between LPM and the WDT. When I turn off LPM I make it further in my code to points where I expect it should reset. Thank you for all your help!
AaronInSpace
 
Posts: 8
Joined: Wed Jul 06, 2011 2:04 pm

Next

Return to TI's MSP430

Who is online

Users browsing this forum: No registered users and 0 guests

cron