PDA

View Full Version : Serial Interrupt



kduck63
- 13th February 2011, 18:12
i am looking for a way to trigger a interrupt event when i send a serial command to a pic from a pc serial port. i plan on using the serin and serout commands in the program.

Plcguy
- 14th February 2011, 17:50
http://www.picbasic.co.uk/forum/showthread.php?t=10521&highlight=serial+interupt

Charles Linquis
- 14th February 2011, 22:04
Although it is possible to do what you say (if you pick your RECEIVE pin on Port B), I really wouldn't use SERIN/SEROUT. If your device has a hardware serial port - use it. Interrupts are far, far simpler that way.

If you have no hardware serial port, and you absolutely must have an interrupt, I wrote some code 2-3 years ago that gets the job done. It might take me awhile to find it, though.

But do you best to use the hardware first....

kduck63
- 15th February 2011, 00:19
Thank you for the suggestion. By going with the hardware serial port i would need to use another chip like a max232, right? I have had pretty good luck with serin2 and serout2 in the past; I think i will give the portb interrupt a try.

Charles Linquis
- 15th February 2011, 02:19
Not true

Some chips, like the 18F2321 that I like to use for small projects, have two bits (BAUDCON.5 and BAUDCON.4) that let you invert the hardware serial port for both transmit and receive. No MAX232.

Ioannis
- 15th February 2011, 10:28
In this case you need to cautious as the level will not be true RS-232 but still TTL.

Ioannis

kduck63
- 15th February 2011, 13:45
i was considering using a 18F2553 which does have the baudcin bits. If i set them appropriately, is it a similar hook up as shown in the pbp manual with the current limiting resistors?

Charles Linquis
- 15th February 2011, 13:58
While I don't recommend the "no MAX232 approach" to anyone - certainly not for a production unit, it works. If it works on a SERIN pin, it will work on a HSERIN pin as well.

There is only one small drawback to using the hardware in the way I mention - you can't set it for open-collector (open drain) operation without an external transistor or gate. That mode can be very useful in small networks.