HSERIN with/without interrupt


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default

    You are probably better off reading PIR1.5 in your loop. This is a flag that is set whenever the USART has a character in the buffer. It is extremely fast and doesn't waste time if no characters are waiting in the buffer. Just Put a 'IF PIR1.5 THEN...' in your main loop. If it is set, then go to HSERIN and read the characters. Put a small timeout on the HSERIN so it jumps out if ALL the expected characters aren't read.
    Of course, this technique generally works best if the USART isn't going to get flooded with a continuous stream of characters.

    The PIR1.5 flag gets set whenever the first character comes in, but the buffer holds up to two characters, so you actually have two character "times" to get the buffer read. The HSERIN command clears PIR1.5 when the character(s) are read.
    Charles Linquist

  2. #2
    Join Date
    Jul 2008
    Location
    devon
    Posts
    15

    Default

    Thanks for the suggestions.
    Using PIR1.5 I am getting some response but it only works once in the loop.
    Below is my new simplified loop for testing.
    I am sending the data from the PC myself manually so there is no barrage of data for it to deal with. You say the PIR1.5 is set to 0 after reading (HSERIN?) but is the buffer also cleared or is there an instruction for that?
    I thought the buffer held more than 2 characters. . .
    Basically all I want to do is for the PIC to read the buffer constantly, perform one of 3 routines depending on the character "a" "b" "c", then go back to the loop and start reading for another character.
    Any advice appreciated. Thanks

    loop:
    vbin = 0 ' reset VBIn
    pause 1000
    mybuzzer = 0
    if pir1.5 = 1 then ' suggestion from forum, character in buffer
    hserin [vbin]
    sound mybuzzer,[60,10]
    hserout [vbin]
    Endif
    goto loop

Similar Threads

  1. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  2. TMR0 interrupt and HSERIN
    By boban in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd September 2008, 11:48
  3. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  4. Can a TMR interrupt stops HSERIN?
    By SergioRM in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th January 2006, 01:07
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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