Very Trouble with 8722 Interrupt


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    2

    Unhappy Very Trouble with 8722 Interrupt

    In many case (but random) when PIC18F8722 go to IRQ handler, some Ram variables changes their value with dramatic conseguence in the flow of process. This is the source of IRQ :
    '************************************************* *********
    ' Assembly language INTERRUPT handler
    Asm
    GlbInt
    ;^^^^^
    ; Save the state of critical registers
    ;************************************************* *************************************************
    ; Select How Interrupt Occur
    MOVWF wsave ; wsave is W
    MOVFF STATUS, ssave ; ssave is STATUS
    MOVFF FSR0, fsave ; fsave is BSR
    MOVFF FSR1, fsave1
    MOVFF FSR2, fsave2
    MOVFF BSR, bsave
    ;
    RXF btfsc _RC1IF
    call _RxIRQ ; Routine Interrupt EUSART1 Receiver
    ;
    T0F btfsc _TMR0IF
    call _timer0IRQ ; Routine Interrupt Timer0
    ;
    T1F btfsc _TMR1IF
    call _timer1IRQ ; Routine Interrupt Timer1
    ;
    ;************************************************* *************************************************
    ; Restore
    finished
    ;
    MOVFF bsave, BSR
    MOVFF fsave2, FSR2
    MOVFF fsave1, FSR1
    MOVFF fsave, FSR0 ; Restore BSR
    MOVFF ssave, STATUS ; Restore STATUS
    MOVF wsave, W ; Restore WREG
    RETFIE
    ;
    EndAsm
    '
    asm
    '************************************************* ********
    ' Those the IRQ variables :
    '************************************************* ***************
    'Interrupt used variables
    wsave var byte $100 system ' Saves W
    ssave var byte $101 system ' Saves STATUS
    fsave var word $102 system ' Saves FSR0
    fsave1 var word $104 system
    fsave2 var word $106 system
    bsave var word $108 system


    Can I make something ???? Thank's so much. Pheraps isn't valid save stack routine for this MCU. I'ved copy this for a 16f877 MCU and adaptate to 18f8722.

    Sorry for language.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I'm not a 18F Specialist ...

    but smells Some Banking issues ... ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    • The constants FSR0, FSR1 and FSR2, are only for use with the LFSR (Load File Select Register) opcode.
      They equate to 0, 1 and 2 respectively.
      Using them with MOVFF, causes it to save/restore the memory at locations 0, 1 and 2, which are normally PBP's system variables.

      On 18F's, the FSR's have 12-bit addresses, so it takes 2-bytes to hold each one.
      For FSR0, the actual values are in FSR0L and FSR0H. If you are saving them, you need to save both.

      But you only need to save the FSR's if they are also used by the interrupt handler. If you're handler doesn't use them ... it's just waisting time.
       
    • The MOVWF opcode, requires that the BANK be set first, but you can't set the bank at that point, because the BSR register hasn't been saved yet.
      Use MOVFF WREG, wsave instead.
       
    • If you are using High Priority interrupts? Then you don't need to save WREG, STATUS or BSR. They are automatically saved by the CPU when the interrupt occurs.
      Then use RETFIE 1 (FAST return).
       
    • You are calling routines with underscores in front of them.
      You aren't calling BASIC code from an ASM interrupt are you?
    DT

  4. #4
    Join Date
    Jan 2009
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Well then I must only use a RETFIE FAST and no "PUSH/POP" anythings in IRQ routine.
    as :


    Code:
    ' Assembly language INTERRUPT handler
    Asm
    GlbInt
    ;
    ;
    RXF btfsc _RC1IF
    call _RxIRQ ; Routine Interrupt EUSART1 Receiver (in basic code)
    ;
    T0F btfsc _TMR0IF
    call _timer0IRQ ; Routine Interrupt Timer0 (in basic code)
    ;
    T1F btfsc _TMR1IF
    call _timer1IRQ ; Routine Interrupt Timer1 (in basic code)
    ;
    ;**************************************************************************************************     
    ; Restore 
    
    RETFIE FAST
    ;     
    EndAsm
    Is possible getback any confirm or suggestion ?
    Thank'you very much.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by smarino View Post
    Is possible getback any confirm or suggestion ?
    Since you are trying to call BASIC language routines from an ASM interrupt ... there is only one thing I can recommend....

    DT_INTS-18
    http://darreltaylor.com/DT_INTS-18/home.html
    <br>
    DT

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. Replies: 10
    Last Post: - 2nd May 2009, 07:42
  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 : 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