Grabbing word from UART buffer


Closed Thread
Results 1 to 2 of 2
  1. #1

    Question Grabbing word from UART buffer

    Hello,

    I wrote a snippet a while back (3yrs) and have recently picked it back up for reuse. I have a UART packing a variable and incrementing a counter before jumping out of an ASM interrupt routine. I want to pick up 2 bytes (1 word ) from the UART receive buffer. At this time I have the code working on grabbing 1 byte. How do i grab 2 bytes from the UART with one interrupt? Is there a special ASM designation to command a double byte transfer from the RCREG buffer into a variable? My application is to receive a manchester encoded word and decode it to a byte.

    Nick

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    How do i grab 2 bytes from the UART with one interrupt? Is there a special ASM designation to command a double byte transfer from the RCREG buffer into a variable?
    Typically, it's not a good idea to get both with the same interrupt.

    As soon as the first byte is received, you'll get an interrupt. It jumps to the handler, get's the first byte, than has to sit around twiddling it's thumbs while it waits for the second byte to come in very slowly over RS232. If there are other interrupts involved, they will be blocked until the second byte is in.

    Instead, you should only grab 1 byte at a time. Have the handler keep track of whether it's the first or second byte, and after it's received both bytes, set a flag or run the required routine in the handler.

    But to answer the original question...
    When you get to the Handler, grab the first byte, then wait for RCIF to become 1 again. Now you can grab the second byte and have the whole word.
    DT

Similar Threads

  1. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  2. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  3. Grabbing word from UART buffer
    By Macgman2000 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th August 2008, 16:13
  4. DS2760 Thermocouple Kit from Parallax in PicBasicPro
    By seanharmon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th July 2008, 23:19
  5. calculation problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2006, 15:23

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