SEROUT baudrate not correct in combination with 22.1184 MHz?


+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    181
    Thumbs Up
    Received: 2
    Given: 1
    Total Downloaded
    741.23 MB

    0 Not allowed!

    Question SEROUT baudrate not correct in combination with 22.1184 MHz?

    Hi people!

    For my project I use both UART's of the 18F45K22.
    To get 0% timing error for this, the PIC runs on a so-called baud rate crystal of 22,1184 MHz.

    During the program development, I always make temporary use of a serial display that runs on 2400 Baud and control with the software instruction SEROUT.
    However, if the PIC runs at 22.1184 MHz (and I specify XTAL = 22 in the PIC program according to the manual), then the serial display shows nothing but clutter.
    If I run the PIC on 16, 18, 20 or 24 MHz everything is OK.

    My conclusion is that SEROUT does not have the correct baud rate if I specify XTAL = 22, in combination with a crystal of 22.1184 MHz.
    Can this be correct?

    Frizie
    Ohm sweet Ohm: www.picbasic.nl

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,560
    Thumbs Up
    Received: 76
    Given: 33
    Total Downloaded
    6.56 GB

    0 Not allowed!

    Default Re: SEROUT baudrate not correct in combination with 22.1184 MHz?

    Looking at page 240 of the manual, I think you can adjust the rate of the baud rate to accommodate your xtal.

    For example, for 8-bit no-parity, inverted @2400 baud rate the value of the 16-bit is 16780.

    Tweaking the first 12 bits, (0 to 11), you can slightly increase or decrease the baud rate so you make it works. It is like HRSout with internal oscillator, you have to tweak the internal oscillator to make the transmission correct.

    So for the example I gave above, maybe 16870 will work for your 22.1184MHz crystal.
    Regards

    Joseph

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    181
    Thumbs Up
    Received: 2
    Given: 1
    Total Downloaded
    741.23 MB

    0 Not allowed!

    Default Re: SEROUT baudrate not correct in combination with 22.1184 MHz?

    Yes, that helps.
    Thanks for the tip Joesaliba, I could have known it myself but I had not thought about it.
    I have those values from the table from the manual in an include file.
    It contains for example:

    SYMBOL Baud2400i = 16780 '2400 Baud inverted
    SYMBOL Baud2400t = 396 '2400 Baud true

    On this way I no longer have to search in the manual for the values for the various baudrates.
    The disadvantage is that I now looked no further than my nose is long.
    Of curse is adjusting that value the solution.

    When I print the line "Proton is a top compiler" the display writes: rot is *op co**piler
    When I give 'Baud2400t' a value between 360...394, then the display works now fine at 22.1184MHz!

    So, many thanks to open my eyes Joesaliba!


    Frizie.
    Ohm sweet Ohm: www.picbasic.nl

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,560
    Thumbs Up
    Received: 76
    Given: 33
    Total Downloaded
    6.56 GB

    0 Not allowed!

    Default Re: SEROUT baudrate not correct in combination with 22.1184 MHz?

    Glad I was of help.
    Regards

    Joseph

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,594
    Thumbs Up
    Received: 339
    Given: 162
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: SEROUT baudrate not correct in combination with 22.1184 MHz?

    Using an exact frequency that will divide for Baud rates with the software serial commands serves very little purpose. The software commands use integer calculations and variables for their timings, and instractions around them to create the timings, so a lot of the finer frequencies of the oscillator will be lost anyway when it integer divides. The crystals with the extra resolutions are only useful for the hardware serial commands that have the built in hardware Baud generator.

    If only using the software serial commands, you are better off using a 20MHz, crystal, of higher. The compiler's manual gives the calculations required for the Baud rate of serin and serout the polarity. As Joseph stated, use the calculation then tweek it a bit for non integer crystal frequencies, but you will rarely get the exact Baud rate with the software serial commands.

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    181
    Thumbs Up
    Received: 2
    Given: 1
    Total Downloaded
    741.23 MB

    0 Not allowed!

    Thumbs up Re: SEROUT baudrate not correct in combination with 22.1184 MHz?

    Thanks for reply Les.

    Please read my first message, you'll see that I use both USART's, and with that I use the hardware serial commands.
    But I also temporarily use a serial display for debugging the program during developing the PIC program, to display intermediate results.
    And then I ran into the problem of the baudrate error with SEROUT.
    But ... problem solved!


    I would like to take the opportunity to state that I think Proton is a fantastic compiler, and I have been doing that for many years.

    Frizie.
    Ohm sweet Ohm: www.picbasic.nl

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,594
    Thumbs Up
    Received: 339
    Given: 162
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: SEROUT baudrate not correct in combination with 22.1184 MHz?

    Sorry Frizie. I didn't read the first post thoroughly enough. :-)

    Many thanks for your complement, it is very much appreciated.

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Usart baudrate dynamically change possible?
    By ElektroArt in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 5th July 2011, 12:41
  2. SERIAL baudrate
    By Jezsmith in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 26th March 2011, 16:20
  3. MCloader, from 10 MHz to 4 MHz
    By MadAl in forum Mecanique - IDE
    Replies: 7
    Last Post: 28th December 2008, 16:25
  4. [SOLVED !] Incorrect Compiler BaudRate Calculation
    By Kabron in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 21st March 2007, 15:07
  5. Zero error in USART baudrate
    By GAMBOA in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 2nd March 2005, 16:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts