115200 Baud to 9600 Baud Translator


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You get the error because N2400 hasn't been defined.

    Declare N2400 as a constant first.

    N2400 CON 16780 ' <-- Baud modes shown in manual for serin2/serout2

    Now you can use N2400 with serin2 to set the baud mode.

    Note: Look at the DEBUG / DEBUGIN commands if you want high-speed serial without a hardware USART, odd value or fast crystal. With DEBUGIN you can easily get 115200bps with a 4MHz crystal. You can't with serin2.

    You can use the 16F84A running @20MHz with DEBUGIN receivng at 115200, and serout2 re-sending at 9600, but you'll want a crystal speed > 4MHz for serin2 @ 9600 if you want reliability.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  2. #2
    ScottC's Avatar
    ScottC Guest


    Did you find this post helpful? Yes | No

    Default Debugin

    Bruce,

    Thanks for the info, but to run up the rate, what number do I use for 115200?
    The manual only shows values up to 9600 baud using 4 mhz xtal. Or is there a way to calculate that number or do you "FOOL" PBP by substituting a different xtal?

    Scott

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    As shown in the manual, to find the value for a given baud rate, use the equation (1000000/baud)-20. This doesn't work for serin2/serout2 @ 115200 bps.

    With DEBUGIN it's simple.

    DEFINE DEBUGIN_REG PORTC
    DEFINE DEBUGIN_BIT 7
    DEFINE DEBUGIN_MODE 0 '1 = Inverted, 0 = true
    DEFINE DEBUG_BAUD 115200

    Yes. There are ways to trick PBP into working at higher data rates with serin2 & serout2, but then everything else in your program is whacked timing wise since PBP adjusts timing for everything else based on the defined osc speed.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    ScottC's Avatar
    ScottC Guest


    Did you find this post helpful? Yes | No

    Question 115200 HSEROUT Not Working

    I have been messing with this for a bit and no luck. I am using a 16F873A with UART. I see a burst of data on my scope, but PC does not see it. I also know that I have to invert the signal due to the nature of HSEROUT.

    Is what I have code wise correct?

    Any Ideas? I am using a 22.1184MHz Xtal. code is below.
    Just using this as a test to see if I can get 115200 baud to work. Then I'll try to concour the above issue posted.


    DEFINE OSC 20 ' 20MHz oscillator
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 115200
    DEFINE HSER_SPBRG 2
    TRISA = 0
    TRISB = 0
    TRISC = 0

    PORTB.0 = 1

    START:

    HSerout ["12345",10]
    Pause 1000

    GoTo START
    End

    Thanks,

    Scott
    Last edited by ScottC; - 18th March 2005 at 15:23.

  5. #5
    Ceug2005's Avatar
    Ceug2005 Guest


    Did you find this post helpful? Yes | No

    Default

    try at lower speed
    this what i use , not tested uper 9600

    define OSC 20
    DEFINE HSER_TXSTA 20h ' enable the transmit register
    DEFINE HSER_BAUD 2400
    .
    .
    .' +/-
    HSEROUT [dec sign0,10,dec tempc0,13]

    better to use an MAX 232 to conect at COMx

  6. #6
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 11

  7. #7
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    .... and mode 97 should give 9600 baud with SEROUT2. However, you would probably do yourself a favour by switching to a 20MHz crystal since PBP likes that better, all timings will be correct. 115200 baud works quite well with 20MHz and HSEROUT.

    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 10

    .... will give you 115200 with 20MHz.

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Replies: 14
    Last Post: - 20th March 2008, 13:54
  3. pic18f4520 baud rate change to 115200
    By caltex88 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th September 2007, 08:41
  4. Auto Baud Rate Detection
    By mytekcontrols in forum Serial
    Replies: 10
    Last Post: - 31st October 2005, 02:17
  5. Baud Rate and Timing Calculator
    By picnaut in forum General
    Replies: 3
    Last Post: - 23rd January 2004, 16:48

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