Parity Modes


Closed Thread
Results 1 to 5 of 5

Thread: Parity Modes

  1. #1
    Join Date
    Aug 2005
    Posts
    95

    Default Parity Modes

    I need to output different parity modes using one pic i.e. 9600 8N1 9600 8E1 9600 8O1 from my understanding of the PBP manual I can only choose between even, odd or none using the define command. Im still new to all this serial stuff so I would appreciate if someone could confirm this for me.
    Thanks Sphere.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Hi Sphere,

    If I understand correctly, you want to change parity modes at Run-Time?

    If so, then you are correct. Using either HSEROUT or SEROUT2 you can only change them at Compile-Time.

    If you generate your own parity, and manipulate the registers manually, you can use the USART in 9-bit mode to get the 8E1 and 8O1, and turn off 9-bit mode for 8N1.

    DT

  3. #3
    Join Date
    Aug 2005
    Posts
    95

    Default How

    Thanks for the reply, you where correct about changing parity modes at Run-Time? but still being relativity green around the ears regarding pbp how do I do this.

    Thanks Sphere.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Well, first let's look at how the parity works.

    It's calulated by counting the number of 1's in the byte. For instance the letter "J" which is 01001010, 3 bits are a 1.

    If using EVEN parity, the parity bit will be set to 0, since 3 is not an even number. ODD parity would be 1, if used.

    For the letter "K" 01001011, 4 bits are a 1. So EVEN parity = 1, ODD = 0.

    As for sending that via the USART ...
    First, set up SPBRG, TXSTA and RCSTA like normal. (many other posts here show how to do that)

    Set TXSTA.6 (TX9) to 1.   Selects 9-bit transmission
    The parity bit goes in TXSTA.0 (TX9D)   9th bit of Transmit Data
    Then put the byte to be sent in TXREG
    and away she goes.
    DT

  5. #5
    Join Date
    Aug 2005
    Posts
    95

    Default Thanks

    Ill give it a go over the weekend.
    Thanks again Sphere.

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  2. Even Parity
    By Andre_Pretorius in forum Serial
    Replies: 2
    Last Post: - 17th July 2007, 16:48
  3. SEROUT or HSEROUT "ODD" parity
    By RFsolution in forum Serial
    Replies: 7
    Last Post: - 9th December 2006, 11:34
  4. 8 data and parity using HSERIN, HSEROUT
    By Smity42 in forum Serial
    Replies: 2
    Last Post: - 3rd April 2006, 02:45
  5. Debug with parity?
    By cmolson in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd December 2005, 01:23

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