I would do the RS-232 handling via interrupts. That way your program can go it merry way. 1) When communication data is received the normal process will be interrupted 2) The interrupt will receive the data. 3) The data will then be ready to be placed into a variable that your code can handle. The first tutorial covers use of the USART. The second tutorial explains interrupts, The third tutorial is about interrupts and the USART Via Dean Camera at www.avrfreaks.net A tutorial on Using the USART with AVR-GCC ttp://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=45341 I would think that replacing the 'while' with an 'if' there would check to see if something has been received then doing getting that data would not tie up the process just waiting for data. A tutorial titled Newbie's Guide to AVR Interrupts http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=89843&highlight=interrupts A tutorial on Interrupt driven USARTs http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=48188&highlight=interrupts If you are not a member of www.avrfreaks.net it would help you to join up. It free. Also, www.smileymicros.com has valuable info and books on AVR micros. Smiley is almost a daily contributor on AVRFreaks. For a lot of operations with AVRs I feel interrupts are the way to go because they free up the micro to do the mundane chores and only interrupt that as needed. Mike Linux since March 2004 www.counter.li.org Registered Linux User: #482134 Taking up Linux Ubuntu and give-up the Windos habit. Hasta la Vista, Baby. I won't be back! Mike Bronosky Mike@Bronosky.com [Non-text portions of this message have been removed]
Message
Re: [AVR-Chat] Timeout detection Serial RS232 USART
2011-05-24 by Mike Bronosky
Attachments
- No local attachments were found for this message.