On Thu, Mar 22, 2007 at 11:28:53AM -0400, Mike Bronosky wrote: > All this is fine. But for many of us hobbyists that know just enough > about C, especially when it comes to AVRs, to be > down-right-dangerous... > > For me something like the following, is good, proper and works. It is not > fully understood until I dissect. > while ((UCSRA & (1<<UDRE))==0); > > while(UCSRA.5 == 0); //while(USART Data Register Empty) > Haven't tried this but I think it should work and means "while the > data register is empty sit right here". *I* see what you intend but I don't think the compiler will. "5 is not a member of the struct UCSRA". In fact UCSRA isn't a struct at all so the dot thing won't work. Also suggest one pretty-print the while() usage something like this so that it stands out like a sore thumb that one has a small loop: while ((UCSRA & (1<<UDRE))==0) ; > Now to the Xsperts may disagree. I'm a hobbiest, it works for me and > best of all I understand why it works. As a general rule its always bad to write loops with only one possible exit. At the least you should provide a time out exit. Or enable the watchdog timer and kick the dog once prior to entering the above loop. -- David Kelly N4HHE, dkelly@HiWAAY.net ======================================================================== Whom computers would destroy, they must first drive mad.
Message
Re: [AVR-Chat] Re: Some C help please !
2007-03-22 by David Kelly
Attachments
- No local attachments were found for this message.