Handling Serial 8N2


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2003
    Location
    Sydney, Australia
    Posts
    126

    Default Handling Serial 8N2

    I have an industrial controller I need to interface with that uses a serial interface running at 8N2.

    I've had a quick look through the PBP and the midrange PIC manuals and the only way I can think of doing this is by using the 9 bit mode of the internal UART and setting it to be low for the transmit, and just ignoring it on reception.

    Am I missing something obvious ??

    Thanks,
    Bill.

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    I think you are correct (about how to do 8N2) except the hardware UARTs are "true" meaning they idle high - therefore the stop bits need to be high. Using software, you can run true (idle high) or invereted (idle low) using serin, serout, etc.

    also see this thread for a semi-related discussion

    http://www.picbasic.co.uk/forum/showthread.php?t=1749
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Thinking about it .... you can just use SERIN and SEROUT in regular 8N1 format:

    Receiving - 8N2 instead of 8N1 is of no consequence since the stop bit is the same as the idle position (the extra stop bit will be ignored with no effort on your part)
    .
    Transmitting - you can use “DEFINE CHAR_PACING VALUE” to pause between transmissions of each byte. (Just pause the length of on bit transmission to get the second stop bit)

    What baud rate do you want? (e.g., VALUE above would be 104 or more for 9600 baud.) See the PBP manual.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    Join Date
    Feb 2003
    Location
    Sydney, Australia
    Posts
    126


    Did you find this post helpful? Yes | No

    Default

    Hi Paul,

    38400 is the baud rate. I like the idea of using the pacing, but I am pretty sure that the SERIN / SEROUT combos are limited to 19200 max in terms of Baud Rate. 38400 is easy with a hardware UART and a 20MHz crystal.

    I think I'll grab a bit of proto board and a 16F and see if I can fool around with some code to get it working.

    Thanks,
    Bill

  5. #5
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    You had mentioned "setting it low for transmission" which is what you would do if you wanted inverted 8N2. The hardware uses true (idle high).
    38400 is the baud rate. I like the idea of using the pacing, but I am pretty sure that the SERIN / SEROUT combos are limited to 19200 max in terms of Baud Rate. 38400 is easy with a hardware UART and a 20MHz crystal.
    You could: DEFINE OSC 10 but use your 20 and get 38400 out of SERIN and SEROUT. IF you do, watch your other timing issues like Pause (see section 7.1 of the PBP manual).
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

Similar Threads

  1. Replies: 33
    Last Post: - 19th March 2010, 03:02
  2. Dynamic USB Serial Number (PIC18F4550)
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2009, 17:03
  3. Serial data to USB
    By cooksydesign in forum USB
    Replies: 18
    Last Post: - 29th October 2008, 15:10
  4. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39
  5. interfacing to the pc serial port
    By kelangfei in forum General
    Replies: 4
    Last Post: - 7th October 2007, 22:35

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