PIC with Automatic Context Saving


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: PIC with Automatic Context Saving

    Hank, Please note from the first post that an advantage of interrupts without DT_INTS is a major saving in code space. My sample program compiled with 625 fewer program words when using the 16F1828 vs. a 16F690.

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: PIC with Automatic Context Saving

    Hi Dick....thanks point noted. As it goes, while saving space is always welcome the 16f1828 has a reasonable amount - plus, my intended program is going to be very small.

    While I've got you ear....do I just use the syntax exactly as per your example, ie.....

    Code:
    ASM
    RDT                     
      BCF   IOCAF,IOCAF1   ;clear IOCA negative change interrupt flag
      BCF   INTCON,3       ;disable interrupt on change by clearing INTCON bit 3
      BCF   PORTC,5        ;turn on led solid 
      RETFIE               ;return to main
    ENDASM
    ie headed up by an ASM label with no colon, then on the following line the label as defined by the DEFINE INTHAND command?

    Any idea how two interrupts are catered for? (yes, I know DTS_INT handles multiple interrupts already, but just wondering how to do it manually)

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


    Did you find this post helpful? Yes | No

    Default Re: PIC with Automatic Context Saving

    Quote Originally Posted by Dick Ivers View Post
    Hank, Please note from the first post that an advantage of interrupts without DT_INTS is a major saving in code space. My sample program compiled with 625 fewer program words when using the 16F1828 vs. a 16F690.
    The test program I ran in post #14 compiled to 133 words without DT-INTS, and 153 words with DT_INTS.
    I don't think the code savings was due to not using DT_INTS.

    That's using an ASM type INT_Handler. If using a PBP type handler, it goes up to 285 words.
    But that's not a good comparison, because if you want to do PBP type interrupts without DT_INTS the program will get huge from all the checks placed between every line of code.
    DT

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


    Did you find this post helpful? Yes | No

    Default Re: PIC with Automatic Context Saving

    FYI: BCF IOCAF,IOCAF1 in your int handler is probably not doing what you think. IOCAF is in bank 7 on the 16F1828, and PBP resets the bank to 1 when you use ASM. It's up to you to make sure you're in the correct register bank in your .asm routines.
    Regards,

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

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: PIC with Automatic Context Saving

    Bruce, Thanks for the info re. IOCAF bank switching in the handler. Actually, I don't think I need that line of code anyway. As stated in the header, the test program is for one-time use only. The circuit works correctly as is.

    Hank, With two interrupt sources you would first go to the handler identified after DEFINE INTHAND. Once there, set up a test to determine which interrupt occurred by polling the interrupt flags. Then carry out the appropriate interrupt action. I have never done this, so maybe Bruce or Darrel could help with a better explanation.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: PIC with Automatic Context Saving

    Hint: BTFSS or BTFSC, or BIT?GOTO
    ;************************************************* ***************
    ;* BIT?GOTO : Macro - Bit test and Long Goto *
    ;* *
    ;* Input : Cstate = constant desired state for goto *
    ;* Regin = register *
    ;* Bitin = bit *
    ;* Label *
    ;* Output : None *
    ;* *
    ;* Notes : Preserves C, Z, handles page boundaries, resets bank.*
    ;************************************************* ***************
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: PIC with Automatic Context Saving

    16F1828 now working with two interrupt sources.
    BTFSS works well as a source selection tool ... thanks Steve.
    Automatic context saving feature of the chip working.
    End of story.

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