Avoid HSEROUT command?


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Avoid HSEROUT command?

    Quote Originally Posted by Art View Post
    Don’t know why it would interfere with an interrupt, but I mean this
    Code:
    led off
    hserout[a,b,c,d,e,f,i,j]
    led on
    is no better than doing the same thing with software serial.
    The led won’t turn on until all eight bytes are sent.
    Code:
    led off
    hserout[byte]
    led no
    Where as the above doesn’t even have to wait for the single byte to send serially.

    If you were going to interrupt this:
    Code:
    sendingserial = 1
    hserout[a,b,c,d,e,f,i,j]
    sendingserial = 0
    You’d have to be sure your interrupt doesn’t change any vars a-j while sendingserial = 1 or you’d end up
    with a composite of what was supposed to be two commands (i.e. you don’t know where it’s up to).
    You say that I should use a low priority interrupt for sending all my bytes?

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Avoid HSEROUT command?

    I don’t know if you are sending serial in the interrupt or main program, and assumed it’s in the main program.
    Having said that, I can’t think of a reason you need to do serial in the interrupt, but there might be a reason.
    I’m saying sending a slab like that will ruin the illusion of doing things simultaneously like programs do,
    and that there’s no recovering from it.

    Think if you did this:
    Code:
    hserout[a,b,c,d,e,f,i,j]
    Then later you wanted the same program to also receive a serial command that could arrive at any time. You’re screwed.
    For example if a GPS sent it’s data sentence to your chip while in the middle of your program sending that eight byte slab.

    But you can easily have a fully duplex serial port with PBP HSEROUT.
    You can be sending the eight byte slab at the same time as receiving something,
    and once implemented you barely have to think about it.

    Code:
    atoj var byte[8]
    rxbuffer[8]
    index var byte
    rxindex var byte
    serbuff var byte
    rxbuff var byte
    
    mainloop:
    
    ‘ your program
    
    if index > 7 then ‘ data packet was sent, so send another.
    index = 0’
    endif
    
    if rxbuff = enterkey then ‘ check for end of incoming command
    rxindex = 0
    ‘do something with received command
    endif
    
    
    if index < 8 then
    serbuff = atoj[index]
    hserout[serbuff]
    index = index + 1
    endif
    
    if rxindex < 8 then
    hserin[rxbuff,shortesttimeout,donelabel]
    donelabel:
    rxbuffer[rxindex] = rxbuff
    rxindex = rxindex + 1
    endif
    
    goto mainloop
    Last edited by Art; - 27th November 2015 at 05:56.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Avoid HSEROUT command?

    Quote Originally Posted by Art View Post
    I don’t know if you are sending serial in the interrupt or main program, and assumed it’s in the main program.
    Having said that, I can’t think of a reason you need to do serial in the interrupt, but there might be a reason.
    I’m saying sending a slab like that will ruin the illusion of doing things simultaneously like programs do,
    and that there’s no recovering from it.

    Think if you did this:
    Code:
    hserout[a,b,c,d,e,f,i,j]
    Then later you wanted the same program to also receive a serial command that could arrive at any time. You’re screwed.
    For example if a GPS sent it’s data sentence to your chip while in the middle of your program sending that eight byte slab.

    But you can easily have a fully duplex serial port with PBP HSEROUT.
    You can be sending the eight byte slab at the same time as receiving something,
    and once implemented you barely have to think about it.

    Code:
    atoj var byte[8]
    rxbuffer[8]
    index var byte
    rxindex var byte
    serbuff var byte
    rxbuff var byte
    
    mainloop:
    
    ‘ your program
    
    if index > 7 then ‘ data packet was sent, so send another.
    index = 0’
    endif
    
    if rxbuff = enterkey then ‘ check for end of incoming command
    rxindex = 0
    ‘do something with received command
    endif
    
    
    if index < 8 then
    serbuff = atoj[index]
    hserout[serbuff]
    index = index + 1
    endif
    
    if rxindex < 8 then
    hserin[rxbuff,shortesttimeout,donelabel]
    donelabel:
    rxbuffer[rxindex] = rxbuff
    rxindex = rxindex + 1
    endif
    
    goto mainloop
    Thanks Art, it works quite well
    I've no more latency done by the HSEROUT command.

    Thanks!

Similar Threads

  1. ADCIN & 16F870 - how to avoid non linear conversion?
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 21st March 2014, 08:02
  2. How can I avoid stack corruption
    By BrianT in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th August 2013, 02:45
  3. How to avoid DIV32 command?
    By pxidr84 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 16th May 2011, 06:11
  4. How to avoid corrupting an EEPROM Write
    By jessey in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th July 2005, 08:34
  5. 16F877 and Hserout command
    By fbestepe in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 29th May 2004, 10:30

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