Measuring audio phase shift through a circuit with a PIC


Closed Thread
Results 1 to 40 of 50

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    As a relative PIC (& programming) n00b, even I realised that with every interrupt (& there'll be a whole heap of them generated here), some registers need to be stored away to be picked up again once the interrupt has finished. As the incoming audio frequency rises, the interrupt rate gets higher & higher eg at 2.5Khz, that's an interrupt every 400us...but it's worse than that, becuause there are two comparators, so it's actually an interrupt every 200us!

    So if having to store/restore registers every 200us, then it obviously makes sense to use the fastest interrupts - that's where I come unstuck ....I only presently know how to us DT's interrupts! (& I have no clue as to how fast they are vs ASM interrupts ...it's all a bit "Whoah...there goes scary stuff" at the moment!)

    Re your comment...

    I suggest you slim it down by using ASM inside the ISR and avoiding ReEnterPbp. You should see better results.

    bearing in mind the actualy routine is quite small....

    Comp1 Interrupt routine...
    store timer 1 count to a Variable "X"
    reset timer 1


    Comp2 Interrupt routine...
    store timer 1 count to a Variable "y"
    reset timer 1

    ..... would it be possible to at least get me started?

    Re the ISR - how would that be triggered?

    Re the ISR content - what ASM would that entail?

    I'm not expecting anyone to do this for me, but when you don't know where to even start....then any initial guidance is most welcome!

    Edit: Also, are there any suitable tools that can help me work out what's going on inside the PIC - I'm thinking along the lines of simulating in step time (vs real time) & seeing what's going on wrt registers.
    Last edited by HankMcSpank; - 29th September 2010 at 13:30.

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post
    Comp1 Interrupt routine...
    store timer 1 count to a Variable "X"
    reset timer 1


    Comp2 Interrupt routine...
    store timer 1 count to a Variable "y"
    reset timer 1
    First I would combine these as Paul suggested. ASM provided in my above post.

    ..... would it be possible to at least get me started?
    Of course! we will!
    Re the ISR - how would that be triggered?
    triggering is easy, just have to turn on PIE's and GIE.

    Off the top of my head, there is some homework to be done. I am not sure how to share variables between ASM and PBP. I don't have my manual with me at work, but I do remember seeing it. Thats needs to be found. While you are reading it, see if says anything about needing to stack PBP stuff when entering ISR. Pic will take care of the important stuff, but what about bank select and such.

    Re the ISR content - what ASM would that entail?
    Thats the easy part

    Edit: Also, are there any suitable tools that can help me work out what's going on inside the PIC - I'm thinking along the lines of simulating in step time (vs real time) & seeing what's going on wrt registers.
    Do you use MPLAB? If so, I like the mplab sim in under debuggers. it's not real robust, but it will allow you to set things like the input pin, step through the program and watch reg's. I don't know if it works with PBP. Beyond that, hardware solutions start with something like ICD. and higher in the money scale.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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