EmbeddedRelated.com
Forums
Memfault Beyond the Launch

UART receive interrupt wake-up from LPM3 question

Started by Joe Rushlow September 10, 2003
   I have browsed the archived messages with no luck on this matter 
but hopefully someone can help me out.
   I am having a problem regarding LPM3 and waking up by a received 
character on the UART. I am trying to determine the correct use of 
the URXSE bit in the UTCTL register. Basically the behavior is this:
During active mode(AM) the receive ISR appears to work perfectly. I 
can send characters to it at 9600 baud for minutes straight with no 
indication of any problems. 

Essentially my program does this:

bool stayAwake;

void main(void)
{
   stayAwake = true;
   while(1)
   {
      if( stayAwake == true )
      {
         // do nothing
      }
      else
      {
         // go to sleep
         UTCTL0 |= URXSE; // enable start detection
         LPM3;
      }
   }
}

// My interrupt function
interrupt void receiveISR( void )
{
   bool result;
   result = isInLowPowerMode( SR_OFFSET ); // my own function
                             // to determine if we are in LPM
   
   if( result == true }
   {
      LPM3_EXIT;
      UTCTL0 &= ~URXSE; // clear the start edge detection bit
      stayAwake = true;
   }
   else
   {
      // echo the character
      if( RXBUF0 == '4' )
      {
         stayAwake = false;
      }
   }
}


Am I using the URXSE bit correctly? What appears to be happening is 
if I hold down the '4' key in Hyperterminal it kind of
"freezes" but 
then it comes back alive sometimes. The "freeze" can occur anywhere 
between the 20th '4' or up to several hundred characters later. So if 
the CPU is asleep the '4' will wake it up and then will get echoed 
and also set the flag that tells the software to go back to sleep. I 
think my problem may simply be a misunderstanding of the proper way 
to utilize the URXSE bit. Any help would be GREATLY APPRECIATED since 
I've been pulling my hair out over this for the past 2 days. Thanks 
in advance.

-Joe



Beginning Microcontrollers with the MSP430

How are you clocking the UART? If you are using a crystal, it may not 
stabilize fast enough to properly interpret the character.

Mike 
--- In msp430@msp4..., "Joe Rushlow" <joeyrush@y...> wrote:
>    I have browsed the archived messages with no
luck on this matter 
> but hopefully someone can help me out.
>    I am having a problem regarding LPM3 and waking up by a received 
> character on the UART. I am trying to determine the correct use of 
> the URXSE bit in the UTCTL register. Basically the behavior is this:
> During active mode(AM) the receive ISR appears to work perfectly. I 
> can send characters to it at 9600 baud for minutes straight with no 
> indication of any problems. 
> 
> Essentially my program does this:
> 
> bool stayAwake;
> 
> void main(void)
> {
>    stayAwake = true;
>    while(1)
>    {
>       if( stayAwake == true )
>       {
>          // do nothing
>       }
>       else
>       {
>          // go to sleep
>          UTCTL0 |= URXSE; // enable start detection
>          LPM3;
>       }
>    }
> }
> 
> // My interrupt function
> interrupt void receiveISR( void )
> {
>    bool result;
>    result = isInLowPowerMode( SR_OFFSET ); // my own function
>                              // to determine if we are in LPM
>    
>    if( result == true }
>    {
>       LPM3_EXIT;
>       UTCTL0 &= ~URXSE; // clear the start edge detection bit
>       stayAwake = true;
>    }
>    else
>    {
>       // echo the character
>       if( RXBUF0 == '4' )
>       {
>          stayAwake = false;
>       }
>    }
> }
> 
> 
> Am I using the URXSE bit correctly? What appears to be happening is 
> if I hold down the '4' key in Hyperterminal it kind of
"freezes" 
but 
> then it comes back alive sometimes. The
"freeze" can occur anywhere 
> between the 20th '4' or up to several hundred characters later.
So 
if 
> the CPU is asleep the '4' will wake it
up and then will get echoed 
> and also set the flag that tells the software to go back to sleep. 
I 
> think my problem may simply be a misunderstanding
of the proper way 
> to utilize the URXSE bit. Any help would be GREATLY APPRECIATED 
since 
> I've been pulling my hair out over this for
the past 2 days. Thanks 
> in advance.
> 
> -Joe


I am using the DCO at approximately 1MHz. Thanks.

-Joe

--- In msp430@msp4..., "mjruley" <mjriley@a...> wrote:
> How are you clocking the UART? If you are using a
crystal, it may 
not 
> stabilize fast enough to properly interpret the
character.
> 
> Mike 
> --- In msp430@msp4..., "Joe Rushlow" <joeyrush@y...> wrote:
> >    I have browsed the archived messages with no luck on this 
matter 
> > but hopefully someone can help me out.
> >    I am having a problem regarding LPM3 and waking up by a 
received 
> > character on the UART. I am trying to
determine the correct use 
of 
> > the URXSE bit in the UTCTL register.
Basically the behavior is 
this:
> > During active mode(AM) the receive ISR appears to work perfectly. 
I 
> > can send characters to it at 9600 baud for
minutes straight with 
no 
> > indication of any problems. 
> > 
> > Essentially my program does this:
> > 
> > bool stayAwake;
> > 
> > void main(void)
> > {
> >    stayAwake = true;
> >    while(1)
> >    {
> >       if( stayAwake == true )
> >       {
> >          // do nothing
> >       }
> >       else
> >       {
> >          // go to sleep
> >          UTCTL0 |= URXSE; // enable start detection
> >          LPM3;
> >       }
> >    }
> > }
> > 
> > // My interrupt function
> > interrupt void receiveISR( void )
> > {
> >    bool result;
> >    result = isInLowPowerMode( SR_OFFSET ); // my own function
> >                              // to determine if we are in LPM
> >    
> >    if( result == true }
> >    {
> >       LPM3_EXIT;
> >       UTCTL0 &= ~URXSE; // clear the start edge detection bit
> >       stayAwake = true;
> >    }
> >    else
> >    {
> >       // echo the character
> >       if( RXBUF0 == '4' )
> >       {
> >          stayAwake = false;
> >       }
> >    }
> > }
> > 
> > 
> > Am I using the URXSE bit correctly? What appears to be happening 
is 
> > if I hold down the '4' key in
Hyperterminal it kind of "freezes" 
> but 
> > then it comes back alive sometimes. The "freeze" can occur 
anywhere 
> > between the 20th '4' or up to
several hundred characters later. 
So 
> if 
> > the CPU is asleep the '4' will wake it up and then will get 
echoed 
> > and also set the flag that tells the software
to go back to 
sleep. 
> I 
> > think my problem may simply be a misunderstanding of the proper 
way 
> > to utilize the URXSE bit. Any help would be
GREATLY APPRECIATED 
> since 
> > I've been pulling my hair out over this for the past 2 days. 
Thanks 
> > in advance.
> > 
> > -Joe



Memfault Beyond the Launch