Communicate with PC at baud rate :115200 bps


Closed Thread
Results 1 to 15 of 15
  1. #1

    Question Communicate with PC at baud rate :115200 bps

    Hi all,
    I woking on project communicate with Nokia 5110 through serial protocol , but I have a problem that the serial protocol must be at baud rate 115200 bps , so I try PC with PIC16f877a first. I can communicate at 9600 with higher than this the data is not true it's corrupted .
    if anyone can help me ?

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hello iugmoh,
    Need a little more information, over what distance, what kind of wire are you using, are you using max 232 level shifters chips, are you using hand shaking, what oscillator speed is the PIC running, are you using serout, serout2, hserout . . . ? Do a search on character pacing
    http://www.picbasic.co.uk/forum/showthread.php?p=3633
    Last edited by Archangel; - 8th March 2008 at 06:30.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    oky I have these things :
    1- max232 converter
    2- 4MHZ or 8MHZ crystal
    3- PIC16F877A or PIC18f452 or PIC4220

    I make a programm and put the values accoding to formula baud=fosc/(16(x+1)) or baud=fosc(64/(x+1))

    but the data I recived from pic at pc is a strange data not know

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by iugmoh View Post
    oky I have these things :
    1- max232 converter
    2- 4MHZ or 8MHZ crystal
    3- PIC16F877A or PIC18f452 or PIC4220

    I make a programm and put the values accoding to formula baud=fosc/(16(x+1)) or baud=fosc(64/(x+1))

    but the data I recived from pic at pc is a strange data not know
    "4MHZ or 8MHZ crystal" 4mhz too slow 8mhz probably too slow
    go get this from mister e http://www.mister-e.org/pages/picmulticalcpag.html
    using Mister_e's calculator set for 8mhz we get these settings:

    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $24 ' Enable transmit, BRGH = 1
    SPBRG = 16 ' 115200 Baud @ 8MHz, 2.12%
    SPBRGH = 0
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator

    You may need to slow the character pacing a bit. DEFINE CHAR_PACING 1000
    Last edited by Archangel; - 8th March 2008 at 19:28.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5


    Did you find this post helpful? Yes | No

    Default start bit errors

    By default, PIC ports have their OFF or IDLE condition as zero volts. RS-232 however defines the IDLE or steady mark to be negative volts at the 25 pin connector. This means the idle condition between the PIC and the MAX232 chip must be HIGH or positive - the reverse of what you might first think.

    An asynchronous character begins when the receiving device detects the transition from the steady MARK to a SPACE bit. BUT, if you did nothing to the Txoutput pin before that character started, then the line had been in the space condition for some time. i.e. the start bit goes missing and so the character is corrupted.

    Try this.

    HIGH Txpin 'sets the RS-232 connector pin to negative = Mark = Idle
    pause 1 ' lest the line settle and the remote device see the mark condition
    Serout/hserout/serout21 pin, rate, data 'the message now starts with a guaranteed start bit.

    HTH
    BrianT

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by iugmoh View Post
    I can communicate at 9600 with higher than this the data is not true it's corrupted
    Quote Originally Posted by iugmoh View Post
    2- 4MHZ or 8MHZ crystal
    3- PIC16F877A or PIC18f452 or PIC4220
    Says right in the back of the manual that a faster clock speed than 4Mhz will most likely be needed with a 4Mhz crystal, like quite a bit faster.
    If you're using a '452, turn on the 4xPLL and use the 8Mhz crystal. That'll give you 32Mhz to play with.

  7. #7
    Join Date
    Mar 2006
    Location
    INDIA
    Posts
    89


    Did you find this post helpful? Yes | No

    Default

    But i always use 115200 Baud in nokia 3350 sms zone alarm with this code.

    DEFINE OSC 12 ( I use 11.0592 mhz xtal after define osc 12 )

    OUTPUT PORTC.6 '-- SERIAL Port TX
    INPUT PORTC.7 '-- SERIAL Port RX

    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 5 ' 115200 Bauds with 0% error

    HSEROUT [X,Y,Z]

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by precision View Post
    But i always use 115200 Baud in nokia 3350 sms zone alarm with this code.
    Well, that'll work too, because you're using the HARDWARE USART.
    The note at the back of the book is for SERIN(2)/SEROUT(2).
    The O/P didn't specify if hardware or software serial was being used...

  9. #9


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    SPBRGH = 0
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
    Oky with PIC16f877a this give me an error because theses registers are not exist

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by iugmoh View Post
    Oky with PIC16f877a this give me an error because theses registers are not exist
    And a quick look at the '877A datasheet, Table 10-3, would tell you that getting 115,200 baud out of 4 or 8 Mhz isn't going to happen, unless you can somehow magically get a divisor of 1.5 stuff into that byte value.
    You need more crystals in your toolbox.
    Actually, what you need is more variety...

  11. #11


    Did you find this post helpful? Yes | No

    Default

    ok what is the suitable PIC IC needed with crystal to achive this problem

  12. #12
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by iugmoh View Post
    ok what is the suitable PIC IC needed with crystal to achive this problem
    FASTER...that's all...FASTER! Read the Tables and you'll see what I mean.
    A serial link can tolerate X amount of error. So, find the combination of oscillator speeds and serial communication speeds that works for your unique situation.
    I can't help you much more than that...I don't think anybody can...until you do some reading and comprehending the information involved.
    The 16F877A will run at 20Mhz (possibly a bit faster), the 18Fxxxx series will run at 40Mhz (55Mhz in my experience, but not recommended for reliability). Either of those chips that you have been relating to in your threads will work just fine.
    You need more crystals! More oscillators! More freq! More cycles per second! More HERTZ! More variances of direct current per unit of time!
    That's all!

  13. #13
    Join Date
    Mar 2006
    Location
    INDIA
    Posts
    89


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by skimask View Post
    Well, that'll work too, because you're using the HARDWARE USART.
    The note at the back of the book is for SERIN(2)/SEROUT(2).
    The O/P didn't specify if hardware or software serial was being used...
    You 'r right skimask,
    We cannot achive 115200 baud with SERIN2, According to manual and limitation of compiler,
    But i think one day we all will use SERIN2 at 115200 baud as below,

    DEFINE OSC 20
    INCLUDE "My_Lcd.bas"
    INCLUDE "DT_INTS-14.bas"
    INCLUDE "LCDbar_INC.bas"
    INCLUDE "DT_INS-SERIN2.bas"


    B0 var word
    Main:
    @ DT_SERIN2 , 115200, [B0]

    LCDOUT $fe,1, "Value", DEC 5 B0
    pause 200
    goto main

    Sory Sir Darrel Taylor, its impossible for us to achive 115200 baud in serin2 mode without your MAGIC code.
    Last edited by precision; - 9th March 2008 at 09:35.

  14. #14
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by precision View Post
    You 'r right skimask,
    We cannot achive 115200 baud with SERIN2, According to manual and limitation of compiler,
    But i think one day we all will use SERIN2 at 115200 baud as below,
    I don't know if it works or not...but...
    If you DEFINE OSC 4...
    then try to run DEBUG at 9600...
    but actually clock your PIC at 48Mhz...
    (or DEFINE OSC 4, run DEBUG at 19200 and clock at 24Mhz)
    You MIGHT get 115,200.
    Don't know how reliable it'll be though...

  15. #15


    Did you find this post helpful? Yes | No

    Thumbs up Yes It's work

    Oky Here is the code after trial it on PIC16f877a to communicate with PC at 115200 bps baud rate and it's working fine without any error
    ===============================================
    DEFINE OSC 20
    ' Set receive register to receiver enabled
    DEFINE HSER_RCSTA 90h

    ' Set transmit register to transmitter enabled
    DEFINE HSER_TXSTA 24h

    ' Set baud rate
    DEFINE HSER_BAUD 115200

    ' Set SPBRG directly (normally set by HSER_BAUD)
    DEFINE HSER_SPBRG 10

    main:
    HSEROUT ["yes its working",13,10]
    pause 300
    goto main

    end

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. pic18f4520 baud rate change to 115200
    By caltex88 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th September 2007, 08:41
  3. Auto Baud Rate Detection
    By mytekcontrols in forum Serial
    Replies: 10
    Last Post: - 31st October 2005, 02:17
  4. PIC12F675, accuracy of baud rate with Internal Oscillator
    By Chris Mayhew in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st August 2005, 22:41
  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 : 2

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