DPRG
DPRG List  



[Fwd: Re: [DPRG] Serial woes 2]

Subject: [Fwd: Re: [DPRG] Serial woes 2]
From: Kipton Moravec kip at kdream.com
Date: Mon Feb 26 07:45:58 CST 2007

-------- Forwarded Message --------
> From: Kipton Moravec <kip at kdream.com>
> Reply-To: kip at kdream.com
> To: scott at lighthouse21.com
> Cc: dprglist <dprglist at dprg.org>
> Subject: Re: [DPRG] Serial woes 2
> Date: Mon, 26 Feb 2007 07:42:02 -0600
> 
> I don't like to do my if's that way because I get confused about what is
> really going on.
> 
> if (!(UCSR0A & (1 << RXC0)))
> 
> Change it to 
> 
> if ((UCSR0A & (1 << RXC0)) == 0)
> or 
> if ((UCSR0A & (1 << RXC0)) == (1 << RXC0))
> 
> depending on what your intention is.
> 
> Kip
> 
> On Sun, 2007-02-25 at 23:21 -0600, scott at lighthouse21.com wrote:
> > Hello all,
> > 
> > I'm trying to grab characters from a serial data stream coming into an
> > Atmega 88.  If I just debug print them to the LCD I can see the value come
> > through that I'm looking for but if I try to capture it with an IF the IF
> > never runs.  Here's the code snippet:
> > 
> > 	  if (!(UCSR0A & (1 << RXC0))) // See if there's a character waiting
> > 	  {
> > 	     iFoo = ~iFoo; // do nothing if there's no char waiting
> > 	  }
> > 	  else
> > 	  {
> > 		 cFromUART = UDR0; // Get the character from the UART
> > 		 if (cFromUART == 0xF1) // If its a time code message, catch it
> > 		 {
> > 		    sprintf (sTimeCode,"%cTIME%d",12,cFromUART);
> > 			LCDBug (sTimeCode);
> > 			while (1); // Show it on the LCD for ever and ever
> > 		 }
> > 
> > This IF never actually comes through.  If I just run the data straight to
> > the LCD you can see 0xF1 go by a couple of times.
> > 
> > _______________________________________________
> > DPRGlist mailing list
> > DPRGlist at dprg.org
> > http://list.dprg.org/mailman/listinfo/dprglist
> > 
-- 
Kipton Moravec <kip at kdream.com>

More information about the DPRG mailing list