is hserin slow?


Closed Thread
Results 1 to 8 of 8

Thread: is hserin slow?

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Posts
    53

    Question is hserin slow?

    I am attempting to learn how to use serial communications
    using the hardware serial port (16f627A) to receive a byte of data
    but it seems to slow my program. The data looks clean (no noise).
    I was expecting the hserin to quickly read the receive register.
    can skip hserin and I read the rcreg directly? Do I need a interrupt?
    Is there a better way?

    DEFINE HSER_CLROERR 1 ' Automatically clear over-run errors
    define HSER_BAUD 2400
    RCIF VAR PIR1.5
    command VAR
    reponse VAR

    loop:
    if RCIF then
    Hserin [command]
    if command = 120 then
    hserout [reponse] ' respond with data
    endif
    gosub refresh segment display
    gosub read keypad

    goto loop

    or

    loop:
    if RCIF then
    command=rcreg
    if command = 120 then
    hserout [reponse] ' respond with data
    endif
    gosub refresh segment display
    gosub read keypad

    goto loop



    Thanks,

    Mark

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    You forgot DEFINE TXSTA and DEFINE RCSTA stuff. But indeed you can read RCREG directly of course you can. will it be faster??? can't say.
    Here's a link for you
    http://www.picbasic.co.uk/forum/show...1&postcount=11
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jun 2005
    Posts
    53


    Did you find this post helpful? Yes | No

    Smile

    Thanks Steve!

    Is RCREG 2 bytes?
    I only have 1 byte to send, Should I always send 2 bytes
    and always read 2 bytes?

    Thanks,

    Mark

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I think that RCREG can only "hold" 2 bytes.
    If you don't retrieve your data before that 3rd byte comes along, you get an overrun or something. It probably just kicks the first byte it received "off the end".

    ---> picnaut

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    YUP! RCREG is a 2 byte buffer. This help to miss character.
    You don't need to read always 2 bytes ... well yes and no. Just make a check if the RCREG is now empty will suffice.

    and you just need to send 1 bytes at the time as TXREG is a single 1 byte register.

    HTH
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Aug 2005
    Posts
    57


    Did you find this post helpful? Yes | No

    Default

    Here is a couple attached demo programs that might help,written for the 16F877.Modify for you needs.One uses the on interrupt command and the other the interrupt flag.
    Attached Files Attached Files

Similar Threads

  1. Hserin with Instant Interrupts.
    By ronjodu in forum Serial
    Replies: 17
    Last Post: - 30th December 2014, 20:17
  2. HserIn and Interrupts
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th December 2006, 07:15
  3. 16F877a Interupt driven Hserin
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd November 2006, 00:38
  4. Hserin not working...
    By robert0 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 22nd August 2005, 12:25
  5. Hserin
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th November 2004, 15:42

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