Serial Comms with PIC micros


Closed Thread
Results 1 to 4 of 4
  1. #1
    carlsnilsson's Avatar
    carlsnilsson Guest

    Default Serial Comms with PIC micros

    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

  2. #2
    Join Date
    Mar 2003
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Serial comms speeds

    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

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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
    Last edited by mister_e; - 20th September 2006 at 14:33.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    carlsnilsson's Avatar
    carlsnilsson Guest


    Did you find this post helpful? Yes | No

    Default

    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

Similar Threads

  1. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  2. Automatic VB6 to pic serial connection
    By arniepj in forum Code Examples
    Replies: 13
    Last Post: - 10th January 2008, 07:57
  3. PIC to PIC serial comms
    By damiko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th July 2005, 17:40
  4. Serial Com Pic to Pic
    By uludere72 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 31st May 2005, 10:06
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts