16f88 ausart & defines


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: 16f88 ausart & defines

    Hi Dave,
    The 9th bit is handled in hardware as far as physically sending and/or receiving it but the firmware has to actually put that 9th bit into TXSTA.0 pretty much like it has to put the "normal" 8 bits into TXREG.

    Here's a quote from ESUART section of the datasheet for the 18F25K22:
    Parity is not supported by the hardware, but can implemented is software and stored as the ninth data bit.
    HSEROUT handles this nicely but only when tell it to do so by using the DEFINE HSER_EVEN and HSER_BITS 9, for example. So the DEFINE does not ONLY enable the 9th bit transmision/reception by setting bit6 in TXSTA/RCSTA but it also adds code to actually calculate the paritybit and load into TXSTA.0 when transmitting and get it out of RCSTA when receiving.

    One way to see that this is the case, short of looking at the lst/asm files is to compare the filesize of the generated code with and without parity "defined".

    I'd love to find a way to switch this at runtime but currently I have no idea how to do it except abandon HSEROUT/HSERIN completely.

    /Henrik.

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: 16f88 ausart & defines

    Can't you calc the parity yourself based on if you want it? I realize this is not as clean as lettine PBP do it, but it will solve you problem and still allow HSERIN/OUT. I think.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: 16f88 ausart & defines

    I tried to sidestep this issue by using HSERIN set up for 9 bits with even parity for my reception routine and debug at 9600,8,N,1 for my serial lcd driver routine.

    But debug output stops working as soon as the hserin defines are enabled. The debug output is on the Asuart TX side as i was hoping to use HSEROUT so perhaps there is a conflict there?

    Any more ideas?

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: 16f88 ausart & defines

    What about this:

    Do the defines and set it up for pairity. This will make PBP do the math for it.
    Then set the registers to 8 bit before HSEROUT and set them back when done.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: 16f88 ausart & defines

    Now THAT is a good idea! I'll have to play with that in particular application and see how it works.

    Thanks!

    /Henrik.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: 16f88 ausart & defines

    Agreed that is a good idea. can you post your code example when tested.
    I'll do the same If i get round to it first

    OK so assuming i set up HSERIN/OUT for 9 bit even parity

    I do my 9 bit recieve then just before I want to do my 8bit transmit i clear the TXSTA TX9 flag

    Just a thought though if we clear the TXSTA TX9 flag just before we do the HSEROUt won't it just overwrite it immediately?

    Is the TXSTA only loaded once during program execution when the define is executed? I appreciate the parity bit is changed to suit.

    Or am I confused.
    Last edited by retepsnikrep; - 17th March 2011 at 22:37.

  7. #7
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: 16f88 ausart & defines

    Hmmm, good point. I was/am assuming PBP sets and forgets it. setting it on each transmission seems like wasted code.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Members who have read this thread : 0

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