Page 1 of 2

GIE getting cleared somehow

PostPosted: Mon Apr 28, 2008 3:23 am
by Dave Hohl
I have a simple program that consists of the following:
- basic timer ISR, which sets a binary semaphore 16 times a second
- one task, which waits on the binary semaphore

I am doing a source build -- not a library build.

The program runs for a short while (usually anywhere from 4 to 50 timer
interrrupts, but then gets into a state where the GIE bit is 0, at which point
the timer interrrupt no longer gets serviced.

I am using IAR version 4.10 compiler and Salvo Pro 4.2.0. The problem
occurs with both the C and C++ compilers, and with both the small
and medium data models.

The target is an MSP430FG4618. I am using the FET-USB debug interface.

================== My salvocfg.h file is:

code:
#ifndef __SALVOCFG_H
#define __SALVOCFG_H


// *** INCLUDE FILES
#include <io430.h>

// *** CONSTANTS
#define OSUSE_LIBRARY FALSE

#define OSENABLE_BINARY_SEMAPHORES TRUE

#define OSEVENTS 1
#define OSEVENT_FLAGS 0
#define OSMESSAGE_QUEUES 0
#define OSTASKS 1


#endif // __SALVOCFG_H



================== My source code file is:

code:
#include <salvo.h>
#include <assert.h>
#include <io430.h>
#include <in430.h>
#include <intrinsics.h>

OStypeErr rtos_error;


void my_task(void)
{
while(true)
{
OS_WaitBinSem(OSECBP(1), OSNO_TIMEOUT);
}
}

int main(void)
{
OSInit(); // initialize RTOS

// reset the counter to zero
BTCNT12 = 0;

// program for interrupting every 62.5 ms
BTCTL = BT_fCLK2_ACLK_DIV256 | BT_fCLK2_DIV8;


rtos_error = OSCreateTask(my_task, OSTCBP(1), 8);
assert(rtos_error == OSNOERR);

rtos_error = OSCreateBinSem(OSECBP(1), 0);
assert(rtos_error == OSNOERR);

// enable basic timer interrupt
RTCCTL &= ~RTCIE;
IE2_bit.BTIE = 1;

__enable_interrupt();

while(true)
{
OSSched(); // invoke the RTOS task scheduler
}
}


#pragma vector=BASICTIMER_VECTOR
__interrupt void basic_timer_ISR(void)
{
rtos_error = OSSignalBinSem(OSECBP(1));
assert( (rtos_error == OSNOERR) ||
(rtos_error == OSERR_EVENT_FULL) );
(void)LPM3_EXIT;
}



[This message has been edited by aek (edited April 28, 2008).]


Re: GIE getting cleared somehow

PostPosted: Mon Apr 28, 2008 3:36 am
by aek
Hi Dave.

1) Make sure the usual suspects are correct (e.g. that your salvohook_interrupt) is what you want it to be.

2) There appears to be an incompatible optimization in the later versions of the IAR compiler -- can you disable optimizations and verify that it goes away? It should be possible to limit the disabling of optimizations to just salvosched.c and modules that have Salvo tasks in them, once the optimization is identified ..

------------------


Re: GIE getting cleared somehow

PostPosted: Mon Apr 28, 2008 3:45 am
by aek
Here's the bug report ... http://www.pumpkininc.com/ubb/Forum14/HTML/000043.html

Note that it has not yet made its way into our docs ...

------------------


Re: GIE getting cleared somehow

PostPosted: Mon Apr 28, 2008 3:51 am
by Dave Hohl
Interesting. I did try different optimization settings to see if it affected the behavior. Even using the NONE setting I still have the problem.

When is the target date for having a version that preserves the registers across context switches be available? I don't mind taking the RAM hit to get the code working.


Re: GIE getting cleared somehow

PostPosted: Mon Apr 28, 2008 4:06 am
by aek
If you're still having the problem with NO optimizations then it is not the Salvo code or any optimization issues -- it's something else.

There is no announced date on the register-saved model as of yet ...

------------------


Re: GIE getting cleared somehow

PostPosted: Mon Apr 28, 2008 4:09 am
by aek
In fact, looking at your code, are you suppressing GIE in your salvohook_interrupt module?

There's no need to ... it's better to change the interrupt hooks to simply disable and re-enable the basic timer interrupt enable only, since that's the only one that needs it.

However, global control of GIE should work in the current distribution -- that's why the default hooks were written as they are.

------------------


Re: GIE getting cleared somehow

PostPosted: Mon Apr 28, 2008 4:11 am
by aek
Note that the handling of the interrupt hooks is covered in detail in the RA-IAR430.PDF Reference Manual ...

------------------


Re: GIE getting cleared somehow

PostPosted: Mon Apr 28, 2008 4:15 am
by Dave Hohl
I am using the default hook, so yes, it is disabling GIE. My next step was going to be seeing if disabling just the timer interrupt affects things, but even if that works I would be a leery of assuming that the problem was gone.

I will try this tomorrow and let you know what happens.


Re: GIE getting cleared somehow

PostPosted: Mon Apr 28, 2008 5:35 am
by aek
Hi Dave.

Add

code:
WDTCTL = WDTPW + WDTHOLD;

to the start of your app and it will work fine ... it's working here.

Problem was not so much that you were losing GIE, but that it was resetting altogether due to WDT timeout...

------------------


Re: GIE getting cleared somehow

PostPosted: Mon Apr 28, 2008 5:39 am
by aek
Hmm .. spoke too soon -- do see it losing GIE as well ... am working on it.

------------------