Serial Baudrate 115200


Closed Thread
Results 1 to 36 of 36

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Re: Using a "non-DEFINE-listed" oscillator speed

    Yes, I do use a USB-to-serial interface (FTDI).

    I now corrected the BAUDCTL register so as it sends data inverted (no need for a hw inverter anymore).

    As far as I understand this register's function, OSCTUNE calibrates the internal oscillator so I don't think it will affect the baud rate generator (I don't know).

    BTW, how do I measure a "good" 115200bps signal?

    Code:
    ' HSEROUT
     
    ' PIC 16F690 Fuses
    @ __Config _FCMEN_OFF &_IESO_OFF &_BOR_OFF &_CPD_OFF &_CP_OFF &_MCLRE_OFF &_PWRTE_OFF &_WDT_OFF &_HS_OSC
     
    OPTION_REG = %10000000 'PORT A&B Pull-Ups (look WPUA & WPUB)
    ADCON0     = %00000000 'A/D Module
    ANSEL      = %00000000 'Select analog inputs Channels 0 to 7
    ANSELH     = %00000000 'Select analog inputs Channels 8 to 11
    INTCON     = %00000000 'INTERRUPT Control
    'WPUA       = %00000000 'Select PORTA weak pull-ups
    'IOCA       = %00000000 'Interrupt On Change selection
    CM1CON0    = %00000000 'Comparator1 Module
    CM2CON0    = %00000000 'Comparator2 Module
    TRISA      = %00000000 'Set Input/Output (0 to 5)
    PORTA      = %00000000 'Ports High/Low (0 to 5)
    TRISB      = %00000000 'Set Input/Output (4 to 7)
    PORTB      = %00000000 'Ports High/Low (4 to 7)
    TRISC      = %00000000 'Set Input/Output (0 to 7)
    PORTC      = %00000000 'Ports High/Low (0 to 7)
     
    '-------------------------------------------------------------------------------
    ' DEFINEs
    DEFINE OSC 20
    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $24 ' Enable transmit, BRGH = 1
    SPBRG = 42 ' 115200 Baud @ 20MHz, 0.94%
    BAUDCTL = 24 'Transmit INVERTED data to RB7, Enable 16 bit baudrate generator
     
     
    '-------------------------------------------------------------------------------
    LED1    var PORTA.2
    Counter var word
    Counter = 0
     
    TEST:
      Toggle led1
      HSEROUT [dec counter,13,10]
      pause 500
      Counter = counter + 1
      goto test
     
      end
    Roger

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Using a "non-DEFINE-listed" oscillator speed

    The baud rate generator will be accurate. If the formula says you will get 115KBaud with a 20Mhz oscillator, you will.
    If you don't get 115K baud, then you aren't really running at 20Mhz, or the receiving device has an issue.

    I mentioned in another post how to measure just how fast your chip is running - without an oscilloscope.

    (Turn LED ON)
    For X = 1 to 60
    Pause 60000
    Next X
    (Turn LED OFF)

    Wait one hour. If your LED goes off in exactly 60 minutes, your chip is running the speed you think it is. Using a
    calculator, you can measure the actual frequency to about 0.1%

    A useful tool is BRAY's TERMINAL program (Google it). Free, and it lets you set odd baud rates, like 113Kbaud.
    or 120Kbaud.
    Charles Linquist

Similar Threads

  1. Replies: 33
    Last Post: - 19th March 2010, 03:02
  2. Dynamic USB Serial Number (PIC18F4550)
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2009, 17:03
  3. 16f88 internal osc 8mhz max serial baudrate ?
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th December 2008, 23:27
  4. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39
  5. interfacing to the pc serial port
    By kelangfei in forum General
    Replies: 4
    Last Post: - 7th October 2007, 22:35

Members who have read this thread : 1

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