12f1822, serial RX under interrupt, echo program doesn't want to play


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: 12f1822, serial RX under interrupt, echo program doesn't want to play

    Hello Dick

    I tested the same code as above, changing the interrupt handler to the following
    Code:
    asm
    myint:
        banksel PIR1
        btfss   PIR1,5
        goto    int_out
        bcf     PIR1,5
        banksel  RCREG
        movfw   RCREG
        banksel _RX_BYTE
        movwf   _RX_Byte
        banksel TXREG
        movwf   TXREG
        nop
        btfss   PIR1,TXIF
        goto    $-1
           
    int_out:    
        retfie
    endasm
    If in doubt, add another banksel

    I'm not using the code now but I did test it upon receipt of Darrel's input to check it out.
    I have used this part as a battery cell monitor and I can recall scratching my head over the same issue as then.
    Hopefully I'm twice bitten, third time shy

  2. #2
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: 12f1822, serial RX under interrupt, echo program doesn't want to play

    Are you missing a bank select in that code snippet?

    Code:
    asm
    myint:
        banksel PIR1            '                    |B0
        btfss   PIR1,RCIF       '                    |B0
        goto    int_out         '                    |B0
        bcf     PIR1,RCIF       '                    |B0
        banksel RCREG           '                    |B3
        movfw   RCREG           '                    |B3
        banksel _RX_BYTE        '                    |B?
        movwf   _RX_Byte        '                    |B?
        banksel TXREG           '                    |B3
        movwf   TXREG           '                    |B3
        nop                     '                    |B3
        btfss   PIR1,TXIF       '                    |B0 <-- *****
        goto    $-1             '                    |B0
           
    int_out:    
        retfie
    endasm
    If _RX_Byte is in bank 0, then maybe this would work?

    Code:
    asm
    myint:
        banksel PIR1            '                    |B0
        btfss   PIR1,RCIF       '                    |B0
        retfie                  '                    |B0
        bcf     PIR1,RCIF       '                    |B0
        banksel RCREG           '                    |B3
        movfw   RCREG           '                    |B3
        movwf   TXREG           '                    |B3
        banksel _RX_BYTE        '                    |B0
        movwf   _RX_Byte        '                    |B0
        btfss   PIR1,TXIF       '                    |B0
        goto    $-1             '                    |B0
        retfie                  '                    |B0
    endasm
    Last edited by Mike, K8LH; - 6th December 2012 at 02:52.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: 12f1822, serial RX under interrupt, echo program doesn't want to play

    Whatever.

    Darrel's answer covered it.

Similar Threads

  1. Two interrupt sources in one program
    By Art in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th January 2012, 15:12
  2. confused problem with interrupt in a working program
    By illuminator4 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th November 2008, 17:01
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  4. How can i use Interrupt in my program??
    By alabbadi in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th November 2007, 13:28
  5. Simple Interrupt Program
    By eoasap in forum General
    Replies: 5
    Last Post: - 28th October 2005, 16:22

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