RS232 Baud Rate


Closed Thread
Results 1 to 6 of 6

Thread: RS232 Baud Rate

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default Pic Multicalc

    Hi,

    Do a search for Pic Multicalc, it's very useful for setting up the defines etc. Entering an osc of 4Mhz and 3400 or 57600 it gives these values

    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 6   ' 38400 Baud @ 4MHz, -6.99%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 0   ' 57600 Baud @ 4MHz, 8.51%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    You could try these values, however for running at a fast baud rate I would recommend using a 20Mhz crystal on the 16F877A with the following defines

    Code:
    @   __config _HS_OSC 
    
    DEFINE  OSC 20
    
    DEFINE HSER_BAUD    115200        ' Hser baud rate 
    DEFINE HSER_RCSTA   90h           ' Hser receive status init 
    DEFINE HSER_TXSTA   24h           ' Hser transmit status init 
    DEFINE HSER_SPBRG 10                ' 115200 Baud @ 20MHz, -1.36%
    DEFINE HSER_CLROERR 1             ' Hser clear overflow automatically

  2. #2
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    Hi,

    Do a search for Pic Multicalc, it's very useful for setting up the defines etc. Entering an osc of 4Mhz and 3400 or 57600 it gives these values

    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 6   ' 38400 Baud @ 4MHz, -6.99%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 0   ' 57600 Baud @ 4MHz, 8.51%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    You could try these values, however for running at a fast baud rate I would recommend using a 20Mhz crystal on the 16F877A with the following defines

    Code:
    @   __config _HS_OSC 
    
    DEFINE  OSC 20
    
    DEFINE HSER_BAUD    115200        ' Hser baud rate 
    DEFINE HSER_RCSTA   90h           ' Hser receive status init 
    DEFINE HSER_TXSTA   24h           ' Hser transmit status init 
    DEFINE HSER_SPBRG 10                ' 115200 Baud @ 20MHz, -1.36%
    DEFINE HSER_CLROERR 1             ' Hser clear overflow automatically
    Hi Again, ad thanks again for your reply;

    Hi allready used the Pic Multicalc exactly like you post here, however at 38400 and 57600, donīt work Maybe my serial port don't accept that % of error.

    I don' thave a 20Mhz oscilator, i'm going to buy one and then i will make more test.

    Thanks to all.

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