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.
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.
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....
Charles Linquist
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.
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.
Charles Linquist
In this case you need to cautious as the level will not be true RS-232 but still TTL.
Ioannis
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?
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.
Charles Linquist
Bookmarks