HSER baudrate


Closed Thread
Results 1 to 15 of 15

Thread: HSER baudrate

Hybrid View

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

    Default Re: HSER baudrate

    When changing baudrate on the fly, you want to turn off the USART before though.

    RCSTA=0
    SPBRG=xyz
    TXSTA = whatever, assuming it's value change from baudrate to baudrate
    RCSTA=$90
    Steve

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

  2. #2
    Join Date
    Sep 2009
    Posts
    755

    Default Re: HSER baudrate

    Thanks, guys.
    Both examples helped me. Just to see which registers should be set. Today I'll try ..

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

    Default Re: HSER baudrate

    Get the latest version of my PICMultiCalc on this forum, it will give you a good kick.
    Steve

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

  4. #4
    Join Date
    Sep 2009
    Posts
    755

    Default Re: HSER baudrate

    Everything works great. The calculator has really helped me.
    Here's the code if someone needs it.
    Code:
                 IF HSerBaud=0 THEN
                    RCSTA = 0
                    SPBRG = 207 ' 300 Baud @ 4MHz, 0.0% 
                    RCSTA = $90 ' Enable serial port & continuous receive
                    TXSTA = $20 ' Enable transmit, BRGH = 0
                 endif   
                 IF HSerBaud=1 THEN
                    RCSTA = 0
                    SPBRG = 25  ' 2400 Baud @ 4MHz, 0.17%
                    RCSTA = $90 ' Enable serial port & continuous receive
                    TXSTA = $20 ' Enable transmit, BRGH = 0
                 endif
                 IF HSerBaud=$BD THEN
                    RCSTA = 0
                    SPBRG = 25  ' 9600 Baud @ 4MHz, 0.16%
                    RCSTA = $90 ' Enable serial port & continuous receive
                    TXSTA = $24 ' Enable transmit, BRGH = 1
                 endif

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

    Default Re: HSER baudrate


    For safety sake, I would set RCSTA at the end, just after TXSTA.
    Steve

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

  6. #6
    Join Date
    Sep 2009
    Posts
    755

    Default Re: HSER baudrate

    Done. But I don't see what difference it makes.
    Can someone explain?

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

    Default Re: HSER baudrate

    It shouldn't make so much difference, but it's a bit more logical to me

    1. You disable the USART
    2. You set the baudrate and mode
    3. You Enable the USART

    Open the datasheet, and see what else you do when you write 0 or $90 to RCSTA, it does more than just enable/disable the USART.
    Steve

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

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