PDA

View Full Version : RS232 Interupt or buffer



seascan
- 23rd January 2005, 15:18
I was wondering if anyone could point me to a tutorial or can explain to me how to interupt my code when RS232 from a PC comes into my designated pin on an 18F452. Alternatively, is it easier to buffer the RS232 data so I can poll that pin when I can get around to it? How would you set something like this up?

Currently I use the SERIN2 function, however I am worried about missing data from the PC when I am doing other things (like reading sensors, etc.)

Thank you in advance.
Terry Lease

Bruce
- 23rd January 2005, 17:29
If you need to receive serial data in the background, you'll definitely want to use the hardware USART.

MeLabs has an example for the 18F452 that buffers inbound characters using the hardware USART here: http://www.microengineeringlabs.com/resources/samples/18F/serA452.bas

seascan
- 23rd January 2005, 18:17
Bruce,

Thank you for the quick response. I think it will take me a while to digest that tutorial (I have no asm experience). Have you (or anyone else) come across any "Idiot's Guide to the USART"? I'm looking for the basics about what a USART is... and then how to make use of it.

Thanks again.

Terry

Bruce
- 23rd January 2005, 19:28
Hi Terry,

The best book I have ever seen for learning about PIC serial communications in general & the hardware USART - is Serial Communications by Roger L. Stevens from Square-1. It's not for the 18F series, but it is an excellent book for anyone using 14-bit parts.

We carry this book, and you can also find it at Melabs, Amazon.com or at the Square-1 website at http://www.sq-1.com

There's also a decent book specifically for the 18F452 by John B. Peatman titled "Embedded Design with the PIC18F452 Microcontroller", and chapter 18 addresses the USART.

I also recommend reading the PIC18C Reference Manual from Microchip. It's nowhere near the "idiots guide", but definitely a recommended read if you're working with the 18F series.

The hardware USART really isn't all that hard to learn. Just tinker with a few experiments & code examples, read the ref manual & datasheet, and you'll get the hang of it...;o}