Clearing Out RS232 registers


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136

    Default Clearing Out RS232 registers

    Is there a neat/short way of clearing out the registers associated with using RS232 (Serout, Serout2, HSEROUT) so that no 'junk' appears at the other end?

    So far, Ive tried CRs, LFs and so on but still get a messy first line or so

    Regards Bill Legge

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


    Did you find this post helpful? Yes | No

    Default

    When you first power-up, your hardware, registers, buffers can have all kinds of crap lurking. There's no real way of flushing this out, so the best thing I do is send a dummy line containg a dozen Nulls ($00) or so and terminate that with a CR LF. From then onwards, we're open for business.

    Now, it all depends what is connected to what... if at the receiving end you've got an ANSI Terminal, then the next thing you'll send is a Clear-Screen, if it's an Invoicing printer, then you'd send a Page-Feed, POS Terminal you'd eject a couple of inches of paper along with a paper-cut command, etc etc...

    If one PIC is connected to another, then I tend to send things in packets, and I always prefix the packet with some NULLs and a CR LF. The packet always has to have a valid header and a Checksum, otherwise it's dumped.

  3. #3


    Did you find this post helpful? Yes | No

    Default Use the serin qualifier ir WAIT commands

    I get over this problem by always starting with some preamble characters and either the WAIT (n) or QUALIFIER "A" characters. SERIN, SERIN2, HSERIN and DEBUGIN all have the ability to look for a defined character (or a string in the WAIT case) and toss out all the crud before that character or string.

    HTH
    BrianT

Similar Threads

  1. The worst programmer ever to grace this forum - ME!
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2009, 03:21
  2. UART vs software RS232
    By Michael in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 5th September 2008, 18:27
  3. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39
  4. Use the PIC 16f877 or 877A instead of shift registers.
    By tsanders in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th October 2006, 17:23
  5. Set the UCFG register or registers in general
    By eDub in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 23rd July 2006, 19:46

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