SEROUT2 Question ?


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Question SEROUT2 Question ?

    Hi Thanks for reading...

    I have this code :-

    SERIN2 PORTC.5,813, [STR pass\4]

    Reads what I expect great at 1200 Baud.... My question is how do echo what is being entered back to the operator... The above works great but I am finding I have to wait for the 4 charactors to fill before I can get it back using SEROUT2 ?

    Or do I have to do them 1 at at time (1 in/ 1 out)??

    Thank you for help

    Andy

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,562

    Default Re: SEROUT2 Question ?

    Hi Andy,
    High level PBP commands are "blocking" in nature, meaning that while they are doing their thing nothing else gets done. You're asking PBP to receive a string of four bytes so it will sit there and "receive" until 4 bytes are receieved - then it will continue with the next instruction.

    So, yes, if you want to echo back characters oneby one you need to grab them one by one and send them back as they come in. If it's a human typing on keyboard this might work - or it might not. The reason is, as above, while the PIC is busy eching back the character just received it can't also receive the next character (usign SERIN/SEROUT that is).

    Obviously the "best" way to handle these sort of scenarios is to use the hardware USART, if your PIC has one. Using HSEROUT on a byte by byte basis is MUCH faster then SEROUT because the all PBP needs to do is put the byte to be sent into the USARTs transmit register (if there's room). And at the same time abother byte can be coming into the receive buffer of the USART without any involvment of PBP.

    So, if your PIC has a USART I suggest you switch to HSERIN/HSEROUT. Then of course you can take it one step further and use interrupts.

    With that said, doing HSERIN [STR pass \4] won't allow you to echo the characters one by one as it's still blocking untill 4 bytes are received.

    /Henrik.

  3. #3
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Default Re: SEROUT2 Question ?

    hi Henrik

    TY for fast reply.... As I thought only one thing at a time!!

    I am spoilt I work with ABB DCS systems in my day job #spoilt

    So I need to find a workaround ....
    I suspect it will take up a lot more memory than I have available spare

    Thank you again

    Andy

Similar Threads

  1. Serout2 HELP
    By shawn in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th February 2008, 02:47
  2. Serin2/Serout2 Question
    By scottl in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th November 2007, 09:11
  3. Serout2
    By Mostafa in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th April 2007, 07:37
  4. serout2
    By jcleaver in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th February 2007, 23:51
  5. serout2 help please...
    By cpayne in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd March 2006, 19:37

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts