16f88 ausart & defines


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    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!

  2. #2
    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.

  3. #3


    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.

  4. #4
    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!

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: 16f88 ausart & defines

    I'm going to try

    Code:
    DEFINE HSER_BAUD 9600		'Set Baud rate to 9600bps
    DEFINE HSER_BITS 9		'Set to 9 bit mode
    DEFINE HSER_EVEN 1		'Set Even Parity
    DEFINE HSER_CLROERR 1 		'Clear overflow error automatically
    
    TXSTA.6 = 0				'Clear 9 Bit Txd Mode
    See if that works as clearing the 9 bit mode bit for the txd should hopefully
    leave the rxd unaffected and in 9 bit mode.

    Perhaps we can ask the pbpro author to support seperate defines for rxd and txd ausart.

  6. #6


    Did you find this post helpful? Yes | No

    Thumbs up Re: 16f88 ausart & defines

    This seem to work OK!

    So I am receiving my 9600,8,E,1 data on Usart RXD Hserin

    and

    I am driving my lcd display using Usart TXD at 9600,8,N,1 Hserout

    Defines as above in my previous post for parity

    I just cleared the 9 bit register TXSTA.6 once at start of program after defines and seems to work fine!!

    Thanks for all the ideas.

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


    Did you find this post helpful? Yes | No

    Default Re: 16f88 ausart & defines

    Hi,
    I've just tried this at my end and it seems to work fine. The DEFINE sets the RCSTA and TXSTA (once) as well as "tells" the compiler to insert code to calculate the parity bit for each byte it send and receives. If we then "override" and disables the transmision of the 9th bit PBP will still calculate and load that bit into the 9th databit "slot" but it will never get sent out.

    In my particular case I'm swiching between using and not using parity for both RX and TX, at runtime, so I had to add dual HSERIN commands in my receive ISR, like:
    Code:
    If RCSTA.6 = 1 THEN              'If 9th bit reception is enabled we're using parity.
      HSERIN ParityError, [RxChar]
    ELSE
      HSERIN [RxChar]
    ENDIF
     
    Goto OverParityError
     
    ParityError:
    'Handle it here
     
    OverParityError:
    'Continue here....
    Thanks again for pointing this, now pretty obvious, way out!

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default Re: 16f88 ausart & defines

    Ha, talk about coincidence, posting pretty much the same thing at the same time like that. I didn't see your post before writing mine. It's great that you got it working at your end as well!

    /Henrik.

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