Advantages of HSerout over Serout2 and a problem


Closed Thread
Results 1 to 6 of 6
  1. #1
    rpstroj's Avatar
    rpstroj Guest

    Default Advantages of HSerout over Serout2 and a problem

    Are there any advantages to HSerout over Serout2? I think HSerout is capable of higher baud rates correct?

    I am having a problem sending data from a pic16f76 to a PC serial port. I am currently sending the data via Serout2. It seems no matter what the baud rate I can only recieve 8 bytes at a time. The data isn't streaming and it's not going as fast as I'd like. I was going to try to set up Hserout and see if that fiexes the problem. How should the registers be set up? In the PBP manual it has as an example:

    DEFINE HSER_TXSTA 24h
    DEFINE HSER_RCSTA 90h

    But I don't understand this when looking at the data sheet. The numbers don't make sense. HSER_TXSTA is the same as setting the TXSTA register on the pic correct? What does the 'h' mean in '24h'?

    Please help. Thanks.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    'h' - it's just another way of specifying HEX.

  3. #3
    rpstroj's Avatar
    rpstroj Guest


    Did you find this post helpful? Yes | No

    Default

    That's what I thought the 'h' was. I was looking at the hex incorrectly. Anyway, here's the part of my code concerning hserout if anyone can help with my other problems:



    INCLUDE "modedefs.bas" 'Contains mode definitions for

    DEFINE OSC 12 ' Define OSC 12Mhz for HS

    DEFINE HSER_RCSTA 90H ' Enable Hardware USART receive
    DEFINE HSER_TXSTA 24H ' Set Hardware USART parameters
    DEFINE HSER_BAUD 9600 ' Set baud rate to 9600
    DEFINE HSER_CLROERR 1


    TRISA = %11111111
    TRISB = %00001110
    TRISC = %00000000

    ADCON1=2 'Set PORTA to Analog

    'Variables for LCD
    clrSCR CON 12 ' Cntl-L: clear the display.
    posCmd CON 16 ' Position the cursor.
    ESC CON 27 ' Escape code.
    noCurs CON 4 ' no cursor shown

    Q0 VAR BYTE
    adcount VAR WORD
    LCD VAR PORTB.4

    'serout2 defined as 16468=>9600 baud
    '16416=>19200 baud
    '16390=>38400 baud
    Loop:

    Low PORTB.0 'Start conversion
    High PORTB.0 'bring it back to high

    notdone:
    IF PORTB.1=0 Then notdone

    ShiftIn PORTB.3, PORTB.2, 2, [adcount\16]

    IF adcount<10 Then
    HSerout ["0000", DEC adcount, ","]
    'SerOut2 LCD, 16390, ["0000", DEC adcount, ","]
    Pause 500
    GoTo Loop
    EndIF

    IF adcount<100 Then
    HSerout ["000", DEC adcount, ","]
    'SerOut2 LCD, 16390, ["000", DEC adcount, ","]
    Pause 500
    GoTo Loop
    EndIF

    IF adcount<1000 Then
    HSerout ["00", DEC adcount, ","]
    'SerOut2 LCD, 16390, ["00", DEC adcount, ","]
    Pause 500
    GoTo Loop
    EndIF

    IF adcount<10000 Then
    HSerout ["0", DEC adcount, ","]
    'SerOut2 LCD, 16390, ["0", DEC adcount, ","]
    Pause 500
    GoTo loop
    EndIF

    HSerOut [DEC adcount, ","]
    Pause 500

    GoTo Loop

    End
    Last edited by rpstroj; - 11th August 2004 at 20:13.

  4. #4
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    It is not really clear to me what your actual problem is and what you are trying to achieve.

    Anyway there is one thing I would like to mention:

    If you like to use HSEROUT to communicate with a PC you MUST use a level shifert/inverter.
    With HSEROUT you can't toggle the mode (TRUE/INVERTED)

    The serial communication and mode issue has been discussed many times on this forum.
    (try a "search")

    If you would let us know what your hardware setup looks like and what you are trying to achieve we will certainly be able to help.

  5. #5
    rpstroj's Avatar
    rpstroj Guest


    Did you find this post helpful? Yes | No

    Default

    I do have an sp232 chip between the pic and the computer. I'm merely trying to send data from the pic to the computer as fast as possible.

  6. #6
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    rpstroj

    with the following code I achieved a reliable serial communication @ 115200 8N1 on a 18F452 @ 20 MHz
    (MAX232 between PIC and PC)


    '-------------------------
    DEFINE LOADER_USED 1
    DEFINE OSC 20

    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_BAUD 115200
    DEFINE HSER_CLROERR 1

    Loop:

    HSEROUT ["Test 1234567890"]

    GOTO Loop
    Last edited by NavMicroSystems; - 11th August 2004 at 22:31.

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