Instant Interrupts and Capture


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2007
    Posts
    53

    Default Instant Interrupts and Capture

    Hello,

    I am currently working on a project and using Darrell's Instant Interrupts with the CCP1 module in capture mode. I am measuring the period (frequency) of signals in the range 25 to 4000Hz.

    Everything is working nearly as it should however I am having a minor issue which i can't get my brain around at present. At low input frequencies the system is very responsive. As the input frequency increases, the program loop time (and hence system responsiveness) slows down because of the extra time needed to service the extra interrupts generated by the CCP module - this makes sense. What I am trying to achieve is to only take, say, one or two samples per loop. This should make my program loop time the same regardless of input frequency.

    I thought I could achieve one sample per loop by adding the line:

    @ INT_DISABLE CCP1_INT

    as the last line in my interrupt handler and then enabling the interrupt again at the start of the loop by adding:

    @ INT_ENABLE CCP1_INT

    (This assumes, of course, the loop time is longer than the longest period to be measured.) This idea didn't work - the captured values are not consistent. I feel there is something I am missing here.

    I really only need to sample the input signal once (or maybe twice) per program loop however it must be interrupt driven as there are many calculations and other operations to be done at the same time. I tried other methods (Pulsin, using CCP with a loop to test the flag bit etc.) but they are too slow.

    I think I am going about this all the wrong way and would appreciate any input.

    Thanks,

    Andy

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


    Did you find this post helpful? Yes | No

    Default

    It's really hard to say without more info ...

    Does it look anything like Bruce's capture example, here ?
    http://www.picbasic.co.uk/forum/show...3401#post23401

    The second example in that post.
    <br>
    DT

Similar Threads

  1. mS Timer
    By whmeade10 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th September 2020, 12:12
  2. Using hardware capture
    By Bruce in forum Code Examples
    Replies: 14
    Last Post: - 25th March 2012, 05:52
  3. 18F2420, instant interrupts, and TMR0
    By dhickman in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th March 2009, 18:33
  4. Instant Interrupts and HSERIN
    By Rob in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 31st January 2009, 05:13
  5. Measuring change of frequency with PIC
    By Aussie in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th July 2007, 01:47

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