Help configuring 2 CCP interupts


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: Help configuring 2 CCP interupts

    it should also be noted that for a low priority int handler

    wsave,ssave,bsave vars are required to save and restore chips status on entry/exit

    and that the chosen int priority must match settings

    DEFINE INTHAND CCP_INT ' Declare high-pri interrupt handler
    DEFINE INTLHAND CCP2_INT ' Declare interrupt handler


    CapPriEn = 1 'Set CCP1 int to high priority
    CapPriEn2 = 0 'Set CCP2 int to low priority
    also to note that none or the isr's in this thread have made any attempt at ensuring correct banksel
    a few chk??rp lines would make things more reliable

  2. #2
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: Help configuring 2 CCP interupts

    Below is my working ASM interrupt routine. I'm sure it could be improved, but it appears to work 100%. Using only 1 priority interrupt for the CCP module. Thanks for all the help!

    Code:
    ASM
    X_CCP_INT
      BTFSC PIR1,2          ; if ccp1
      BRA CCP_INT           ; goto CCP_INT
      BTFSC PIR2,0          ; if ccp2
      BRA CCP2_INT          ; goto CCP2_INT
      RETFIE FAST           ; outta here 
    CCP_INT
      BTFSS CCP1CON,0       ; capture from rising edge?
      BRA Fall              ; no .. goto falling edge
      MOVFF CCPR1L, _T1     ; get low capture byte into _T1
      MOVFF CCPR1H, _T1+1   ; get high capture byte into _T1
      BRA IntExit           ; outta here
    Fall
      MOVFF CCPR1L, PW      ; get low capture byte into PW
      MOVFF CCPR1H, PW+1    ; get high capture byte into PW
      BSF CF,0              ; indicate last capture
    IntExit
      BTG CCP1CON,0         ; toggle between rising/falling edge captures
      BCF PIR1,2            ; clear capture interrupt flag bit
      RETFIE FAST           ; return/restore W, STATUS and BSR
    CCP2_INT
      BTFSS CCP2CON,0       ; capture from rising edge?
      BRA Fall2             ; no .. goto falling edge
      MOVFF CCPR2L, _T2     ; get low capture byte into _T1
      MOVFF CCPR2H, _T2+1   ; get high capture byte into _T1
      BRA IntExit2          ; outta here
    Fall2
      MOVFF CCPR2L, PW2     ; get low capture byte into PW
      MOVFF CCPR2H, PW2+1   ; get high capture byte into PW
      BSF CF2,0             ; indicate last capture
    IntExit2
      BTG CCP2CON,0         ; toggle between rising/falling edge captures
      BCF PIR2,0            ; clear capture interrupt flag bit
      RETFIE FAST           ; return/restore W, STATUS and BSR
    ENDASM
    Shawn

Similar Threads

  1. Help with configuring
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 17th August 2014, 01:08
  2. Question regarding CCP
    By spcw1234 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th April 2013, 09:55
  3. Configuring 16F616
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th February 2009, 16:28
  4. CCP Module How to ?
    By capitano in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th February 2005, 08:08
  5. need help configuring 16F628
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd March 2004, 18:59

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