PIC with Automatic Context Saving


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    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

    DT_INTS-14 uses the auto context saving in the 16F1's.

    Since you already know how to use them, try them first.
    There are still a few instruction cycles that can be saved by doing it manually, but you probably won't need to.
    Just use an ASM type INT_Handler. They do not have to save PBP system variables.

    50Khz should be no problem.
    DT

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: PIC with Automatic Context Saving

    Thanks Darrel.

    my fixation is that I want to generate sine waves to very high resolution (DDS) - and all the stuff that abounds on the net seems to be assembly....they all typically generate a fixed timebase by way of an interupt & then in the interupt add a number to an accumulator, do a look up from the result then get out asap. I agree that 50khz is not that onerous...but this is just the first step to total world domination (Mwuahahahaha.) & the interrupt rate will inevitably crank up.

    Towards helping me understand this area, (actually I'm just curious) when you say there are still a few cycles that can be saved by going the way I asked about ....do you have a ballpark figure for the auto context saving and your (still excellent!) auto context embracing routine?
    Last edited by HankMcSpank; - 24th August 2011 at 20:55.

  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

    Well, if you're only going to be using 1 interupt source, it will be better without DT_INTS since you don't need to test for which interrupt was triggered.

    I just did a quick test with an incrementing variable and a SIN lookup with an 1827 running at 32Mhz.

    With DT_INTS ... max = 140Khz
    Without ... max = 220Khz

    With 2 interrupt sources the difference is not as pronounced since it has to check which one triggered and jump over the handler that wasn't. DT_INTS always does that.

    The PWM will have to be running much faster than the interrupts or it will be changing dutycycles before a single cycle has completed. Could be trickey.
    DT

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: PIC with Automatic Context Saving

    Cool (& thanks) ....as it goes I will need two interrupts, one to generate the timebase, plus one UART interrupt, so I can feed in required frequency changes externally.

    I will really only need up to 18khz(ish), so your quoted 140khz max is well above what I need....so I'll stick with DT_INTS!

    As an aside, for anyone who holds an interest in DDS for PIC, the best I've found to date is this chap's site....

    http://www.g4jnt.com/pics.htm (specifically, this http://www.g4jnt.com/PIC_DDS.pdf and his accompanying zip file http://www.g4jnt.com/PIC_DDS.zip which has his assembly source code for a 16f628 DDS ....it'll probably a while before I get to try my DDS exploits, becuase I'm still trying to wrap my head around how he made a pseudo 32 bit accumulator on a 16f628 by lobbing together four 8 bit registers & then making them dance)

    I can feel a serious amount of plagiarism coming on though!
    Last edited by HankMcSpank; - 24th August 2011 at 23:35.

  5. #5


    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.

  6. #6
    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)

  7. #7
    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

  8. #8
    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

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