HSEROUT problem at 20MHz


Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Feb 2006
    Location
    Isle of Man
    Posts
    32

    Cool HSEROUT problem at 20MHz

    I am using a PIC18F452, with a MAX232 and the HSEROUT function to communicate with my PC over a 3m long serial cable. My code is based on the famous post on this forum (many thanks!):

    DEFINE OSC 4

    TRISC = %10000000 'PORTC.7 is RX input PORTC.6 is TX output. Using internal USART and MAX232 to interface to PC

    DEFINE HSER_RCSTA 90h 'Enable serial port. Enable continuous receive

    define HSER_TXSTA 24h 'Enable transmit. BRGH=1

    define HSER_SPBRG 12 '103 for baudrate of 2400 @ 4MHz (25 for 9600 @ 4MHz; 12 for 19200 @ 4MHz)
    DEFINE HSER_CLOERR 1 'Automatic clear overrun error

    'Alias definitions
    RCIF VAR PIR1.5 'Receive interrupt flag (1=full , 0=empty)
    TXIF VAR PIR1.4 'Transmit interrupt flag (1=empty, 0=full)

    SerialData var byte 'Variable definition

    pause 100 'Start-up delay
    Main:
    if RCIF then 'Incoming data?
    hserin [Serialdata] 'Take it
    hserout [serialdata] 'Send it
    endif
    goto main


    This provides perfect 2-way comunications at 4MHz with any of the following settings:

    'TXTA 24h with SPBRG 103 (gives 2400 baud)
    'TXTA 24h with SPBRG 25 (gives 9600 baud)
    'TXTA 24h with SPBRG 12 (gives 19200 baud)

    .... but when I change the clock to 20MHz and alter the SPBRG value according to the datasheet, there is no comms at all. For example, although 19200 baud requires SPBRG to be 64, this produces nothing.

    I'm desperate! Any ideas folks?
    Last edited by manxman; - 22nd May 2006 at 12:40.

Similar Threads

  1. I2C Slave with a PIC
    By ralfmayr in forum mel PIC BASIC Pro
    Replies: 129
    Last Post: - 21st August 2016, 17:44
  2. HSEROUT and Commas, What? Help Me Understand
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th July 2009, 19:12
  3. Is HSEROUT corrupting bit 7 ?????
    By Robert Wells in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd October 2008, 16:26
  4. HSEROUT Problem
    By Keith in forum General
    Replies: 2
    Last Post: - 25th June 2005, 15:09
  5. Advantages of HSerout over Serout2 and a problem
    By rpstroj in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th August 2004, 22:19

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