Measuring audio phase shift through a circuit with a PIC


Results 1 to 40 of 50

Threaded View

  1. #30
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cncmachineguy View Post
    I like Pauls approach, Seems to be the least amount of time between Comp1 and 2. one thing I would do, is program his while loop in ASM. This is because I have no idea how many instructions it takes using PBP. I think this will mask the issue of how long it takes to actually enter the handler. Which is what I think above folks are reffering to with the PBP include.

    heres the while loop in asm:
    Code:
         BCF PIR2,6       --> clears the comp 2 int flag
    HERE                    --> label to jump to
         BTFSS PIR2,6  --> test if comp 2 int flag is set
         GOTO HERE     --> not set, go back to test
    CONTINUE            --> Comp 2 int occured, do what ever needs to be done
    The above will take exactly 1 instruction to enter the loop, then 3 inscrutions to to run per loop. now for some math:

    you are running a 20mHz clock, so thats 5MIPS. so 1 instruction takes .0000002 sec to execute. At 1400 htz, each cycle takes .0071428 sec. that devided by 360 = .00000198sec per degree. so you should be able to measure to almost .5 degree. assuming comp2 fires between BCF and BTFSS, thats 3 instrution cycles, or .0000006 sec.(I think BTFSS may take 2 cycles when true)

    Someone please check my math, but these numbers show you have far too much overhead somewhere that can only be explained by the above posts.
    I agree with the maths...and I agree with the summary (something somewhere is taking way too long). Now that I have a few people interested & feeding in ideas , I will pull the breadboard out of cold storage tonight & try Paul's code.


    Bert, re this...

    Code:
         BCF PIR2,6       --> clears the comp 2 int flag
    HERE                    --> label to jump to
         BTFSS PIR2,6  --> test if comp 2 int flag is set
         GOTO HERE     --> not set, go back to test
    CONTINUE            --> Comp 2 int occured, do what ever needs to be done
    That looks like what will happen when comp2 interrupts....but within my program, how do I setup the 'trigger' condition ...ie to get the program to go and do that when a comp2 interrupt has arrived?

    I will feedback the results (it might be late - ie 21.30 GMT-ish .....got to do the 'kids off to bed' rigamrole first! Hey there's an idea...rather than read them Noddy goes to the Seaside, I could read them some of the ASM code put forward by Bert!! )
    Last edited by HankMcSpank; - 29th September 2010 at 13:56.

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