Just want to clarify.  I didn't know about the global <= a word (int) ok on 
global IRQ
vars.  I had used dint() ... eint()  for the calculation of an average updated 
by an
IRQ:

// Global declaration
unsigned int avg[32];
unsigned int loopinc = 0;
unsigned int agvnum = 16;

int Myaverage()
{
unsigned int i;
unsigned long int templong = 0;

    dint( );
    for ( i = 0; i < avgnum; i++ )
        templong += avg[i];
    eint( );
    return ( templong / avgnum );
}

//IRQ
{
    avg[loopinc] = newnumber;
    loopinc++;
    if ( loopinc > avgnum )
        loopinc = 0;
}

But found that it worked correctly either way.  Since the array "avg[]" is 
declared as
unsigned int, I don't have to use dint() eint() correct?
I suppose I should declare avg[] as volitile.
Thoughts?/Thanks.
-Mark


-----Original Message-----
From: Chris Liechti [mailto:cliec...@gmx.net] 
Sent: Monday, June 21, 2004 5:20 PM
To: mspgcc-users@lists.sourceforge.net
Subject: Re: [Mspgcc-users] dint()

Robert Seczkowski wrote:

> Does anyone has idea in what cases use dint()....eint().
> If I run the code with one oscilator, Do I need to use
> dint() when I write to common variable.

it has nothing to do with the clock source.

if you modify a global var larger than a word, you have to use 
dint();nop() ... eint() because the write operation is not elementary 
and a interrupt could occour while accesing the data.

chris


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to