USART question?


Closed Thread
Results 1 to 4 of 4

Thread: USART question?

  1. #1
    Join Date
    Feb 2010
    Posts
    17

    Default USART question?

    If PIR1.5 = 1 Then ' If receive flag then...
    B1 = RCREG ' Get received character to B1

    Endif

    The above code is from melabs sample programs.
    does PIR1.5 clear automatically after B1=RCREG? It's read only???

    The way i understand the above code is that PIR1.5 will go high when a validte data is rec'd in RX but how does PIR1.5 clear is it after reading the RC register?

  2. #2
    Join Date
    Dec 2005
    Posts
    1,073

    Default Re: USART question?

    This is a case where reading the datasheet for your PIC will answer your question.

    But, the answer is that this bit is cleared after reception is complete.

  3. #3
    Join Date
    Feb 2010
    Posts
    17

    Default Re: USART question?

    Thanks for the reply.
    Here is a segment from 16F887 datasheet:



    12.1.2.3 Receive Interrupt




    The RCIF interrupt flag bit of the PIR1 register is set twhenever the EUSART receiver is enabled and there is
    an unread character in the receive FIFO. The RCIF
    interrupt flag bit is read-only, it cannot be set or cleared by software.
    RCIF interrupts are enabled by setting all of the
    following bits:
    • RCIE interrupt enable bit of the PIE1 register
    • PEIE peripheral interrupt enable bit of the INTCON register
    • GIE global interrupt enable bit of the INTCON register
    The RCIF interrupt flag bit will be set when there is an
    unread character in the FIFO, regardless of the state of
    interrupt enable bits.




















    so as long as there is unread data in there the PIR1 will be set and stay set untill the read instruction is executed NOT when recving is completed as you mentioned. I might be wrong but this is how i understand it, Correct me if i'm wrong.

    Thanks
    ,Best regards

  4. #4
    Join Date
    Dec 2005
    Posts
    1,073

    Default Re: USART question?

    The italicized phrase in my first response was quoted verbatim from the 16F88 datasheet. By reception, I think they meant after the transfer to your variable - perhaps, a poor choice of terminology by Microchip.

    There may be differences in the details between chips which is why consulting the datasheet (or consulting Darrell ) is the only way to deal with things like this.
    Last edited by dhouston; - 27th May 2011 at 11:35.

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