Serial port settings for given crystal


Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Oct 2009
    Posts
    583

    Default Serial port settings for given crystal

    Just need some guidance on setting up the defines for serial communications when using a particular crystal.

    I'm using a 20 mhz crystal.

    Here are my config settings

    Code:
    ASM 
      __CONFIG    _CONFIG1H, _OSC_HS_1H
      __CONFIG    _CONFIG2L, _PWRT_ON_2L  
      __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
      __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H  
      __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    ENDASM
    I've cut and pasted code from a previous project but that won't allow connection with the port.

    Code:
    DEFINE HSER_BAUD    115200        ' Hser baud rate 
    DEFINE HSER_RCSTA   90h           ' Hser receive status init 
    DEFINE HSER_TXSTA   20h           ' Hser transmit status init 
    DEFINE HSER_CLROERR 1             ' Hser clear overflow automatically 
    DEFINE HSER_SPBRG 25  ' 115200 Baud @ 40MHz, -0.22%
    SPBRGH = 0
    BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
    ColumnWidth CON 10
    I've tried changing the baud rate to 9600, and different values for SPBRG as I'm not running the PIC at 40Mhz...

    Any help would be appreciated

    Malcolm
    Last edited by Scampy; - 14th December 2013 at 22:54.

Similar Threads

  1. serial port program in c
    By naveenupendran in forum Off Topic
    Replies: 0
    Last Post: - 28th February 2009, 11:47
  2. interfacing to the pc serial port
    By kelangfei in forum General
    Replies: 4
    Last Post: - 7th October 2007, 22:35
  3. PC serial port funny
    By nicjo in forum Serial
    Replies: 13
    Last Post: - 6th February 2007, 05:34
  4. 5v From Serial Port
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th November 2004, 12:49
  5. Replies: 1
    Last Post: - 30th June 2004, 08:07

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