PDA

View Full Version : Serial Comms with PIC micros



carlsnilsson
- 20th September 2006, 06:12
My reading of the PICBasic manual is that serial comms are compiler-limited to 9600 baud. Does anybody know whether the PICBasic Pro compiler extends that to,say, 38,400 baud? How about the Hi-tech PICC Lite C compiler? The heart of my project is multiplexing various serial data streams and sending them out as a single stream. Any advice on PIC micros and best compilers to use?

Carl

btaylor
- 20th September 2006, 12:19
Serial communications (serin/serout - not hserin/hserout) with PBP and a 20 MHz PIC easily goes past 38,400 bps. I use 38,400 bps in several projects for PIC to PIC datagrams.

What I recommend however is that you pace the characters at the transmitter end to allow the receiving device to process the data before the next character arrives.

Serin is a software routine. While that instruction is running, nothing else can happen. SERIN focusses 100% on the character coming in and half way into the stop bit it exits the SERIN routine and processes the character. In general you have only half a stop bit time to process the character before the next one arrives. At 38,400 bps each bit time is approximately 26 uSecs. That means you have only 13 uSecs to process the just received character before the start of the next character. That means you can only execute approximately 60 machine code instructions, or maybe 6 BASIC instructions, before the next character arrives - this is very tight.

By putting a CHAR_PACING 100 (or your choice of delay) statement at the start of your program you will effectively extend the transmitter's stop bit time and give the receiving device more time to process the character before the next character arrives.

HTH
Brian

mister_e
- 20th September 2006, 14:25
I agree with the HSERIN/HSEROUT. For serious and high speed serial comm you should use a PIC with a USART.

I know DEBUG/DEBUGIN is faster.. but how much. i can't say. Maybe it worth a try if your pic don't have USART.

I've i said maybe?

About the best compiler... there's no better between Hi-Tech and PBP. What make the real difference is behind the keyboard. It will also depend how much you want to spend on a compiler... money and time at least.

Both will do the job as well.

Wich PIC... well every have their own spec. Projects are also different. You should choose one that fit to your app.

Personnally i work with around 50 different model. I don't really have favourite.

Some common 12F683, 16F628, 16F88, 16F648, 16F684, 18F2680, 18F4525, 18F4550,18F2550, 18f2525

carlsnilsson
- 21st September 2006, 01:00
Thanks Steve and Brian for useful replies. One difference between PICC-Lite C and upgrading my PBC to PBP is US$200 for the latter, although I am still more comfortable with Basic than C. I accept that's up to "whats behind the keyboard" and learning C is good for me anyway. I was going to try a PIC16F690, which does have a USART.
Carl