PIR1.5 interrupt


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2008
    Posts
    43

    Default PIR1.5 interrupt

    MeLabs support sent me this code today. It only works once. When I check the state of PIR1.5 before the HSERIN command it is a 1. When I check it after the HSERIN command it is a 0. It seems to reset itself. The problem is that it only interrupts 1 time. I never see the interrupt after the first time it fires. What am I missing? Also, how do I format the HSERIN command to keep reading characters until it sees a CR/LF?

    Thanks,
    Bob Hiller
    Lifts for the Disabled LLC


    main:
    IF PIR1.5 = 1 THEN GOSUB receive_data 'check the flag


    GOTO main


    receive_data:
    HSERIN [x, y, z] 'get data, flag is cleared automagically
    RETURN 'back to business

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Have to reset the interrupt flag. Usually in the PIC's datasheet, there's a little blurb behind the explanation for the interrupt bit that says something like " (Must be cleared by software) "
    Code:
    main:
         IF PIR1.5 = 1 THEN
         PIR1.5 = 0
         GOSUB receive_data  'check the flag
         GOTO main
    receive_data:
         HSERIN [x, y, z] 'get data, flag is cleared automagically
         RETURN           'back to business

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    PIR1.5 or RCIF is a read-only bit that gets cleared once the USART RCREG buffer is
    empty. The only way to clear RCIF is to empty the buffer by reading it.

    My guess would be that you're sending more data than you're receiving in the HSERIN
    routine, and this is causing the USART to lock-up. OERR (the over-run bit in RCSTA) gets
    set, and this causes the USART to stop responding.

    If you include the DEFINE HSER_CLROERR 1 option in the init section of your code, PBP will
    automatically clear this condition for you. If not you'll need to do it manually by clearing,
    then setting, CREN (bit 4 in RCSTA) register.

    RCIF never gets set again once OERR is set because this condition inhibits transfer of data
    from the RSR to RCREG register.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    PIR1.5 or RCIF is a read-only bit that gets cleared once the USART RCREG buffer is empty. The only way to clear RCIF is to empty the buffer by reading it.
    Absolutely...That's twice today I've caused a 'derrrrr'. My game is off......

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. 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
  3. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  4. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  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