Measuring audio phase shift through a circuit with a PIC


Closed Thread
Results 1 to 40 of 50

Hybrid View

  1. #1
    Join Date
    Feb 2010
    Location
    USA, New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Hi Jerson,

    Your right, of course, in everything you said. However there is a place for PBP interrupts. First, for beginners (and even people who, like me, use the absolute minimum of assembly) it is simple, straightforward, and easy.

    Second, that high overhead isn't a big factor if used judiciously. For example, here's the entire code for the main loop of one of my products:
    Code:
    On Interrupt goto IntHandler
    INTCON.1 = 0 	'clear the INT0 flag
    PIR1.5 =  0		'clear the USART interrupt
    enable
    '#############
    ' Start of Main Loop
    '#############
    Start:
    	if USB_ON = 1 then
    	  	bConnected = true   
    	else  'USB_ON = 0
    	  	bConnected = FALSE
    	endif	
    
    	if bConnected = false and bStayInFastMode = false then
    		OSCCON =  %10000000		'32kHz, periperals should run in sleep mode
    	endif
    	@ nop
    	@ sleep                                           'snooze soundly until woken
    goto Start
    '############
    ' End of Main Loop
    '############
    disable
    The main loop checks to see if USB (through an FTDI serial converter) is connected, and if so it stays awake. Otherwise it goes to sleep until the interrupt wakes it (which in this case happens to be either a pulse from an external RTC or data in the serial buffer). The other ~1000+ lines of code are after the "disable" so the PBP interrupt overhead is not in them. I'm sure there are other ways to accomplish the same end, but the above works perfectly. I probably could have moved the ENABLE to just before the "@ nop" and saved another few bytes even.

    Incidentally, @ nop and @ sleep are the full extent of my assembly knowledge...8^)

    With all that said, I really end up not using interrupts very much at all (except to wake a sleeping PIC). What I do is look at the interrupt flags when convenient for the code. This keeps it nice and simple and controlled. Like I said before, I am a simple man.

    Again, I'm not disagreeing or disputing anything you said, just trying to carve out some justification for PBP ints for us simpler folk. It just has to work, it doesn't (always) have to be pretty. Ferraris are nice I suppose, but I hear they're high-maintenance and sort of temperamental. I have a real good time kicking around on my little scooter; it certainly gets me there. If someone told me I had to use ASM ints I would have given up before I started.

    I really need to look into these DT Ints that everybody keeps talking about...

    Best Regards,
    Paul

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by prstein View Post
    Hi Jerson,

    there is a place for PBP interrupts. First, for beginners (and even people who, like me, use the absolute minimum of assembly) it is simple, straightforward, and easy.

    [/CODE]

    The main loop checks to see if USB (through an FTDI serial converter) is connected,

    Incidentally, @ nop and @ sleep are the full extent of my assembly knowledge...8^)

    I really end up not using interrupts very much at all (except to wake a sleeping PIC). What I do is look at the interrupt flags when convenient for the code. This keeps it nice and simple and controlled. Like I said before, I am a simple man.

    I have a real good time kicking around on my little scooter; it certainly gets me there. If someone told me I had to use ASM ints I would have given up before I started.
    Hey Paul

    Sorry if I stepped on some toes here. In fact, I was seriously thinking of editiing my post, but, history has had me earlier too So, this is one boo-boo from me to stay here for posterity to see

    Ok, I understand the use of ON INTERRUPT as you use it. My point was about driving home the real-time performance hit and how high the latencies can be. Waking a PIC from sleep? LoL You must be doing much more than that for sure.

    I do not want my post to sound discouraging. Obviously, that will be the first thing a newbie will try when they want interrupts (because.... it is in the Manual)

    I do not have a ferrari either and hope I could buy something better than my old faithful scooter which I have just put up for sale )


    Just to make it clear, I learn new things out here almost everyday. Some of the folks who call themselves newbies and amateurs really astonish me with their coding style. If they only start giving back the little they know, I'm sure they will learn a lot more.

    But, seriously, if you want good realtime performance out of a PIC, DT_ints is the way to go. One more plug for DT_ints

    Cheers

  3. #3
    Join Date
    Feb 2010
    Location
    USA, New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Hi Jerson,

    None of my toes were stepped upon; I appreciate that you presented the the opportunity to discuss my own take on interrupts and regret if I came off as defensive. Mr. McSpank appears to be quite sharp but I worry a little about making the learning curve too steep.

    I truly appreciate reading your posts--please don't hold back because of me!

    Your scooter looks nice but the shipping charges would be prohibitive...and my Kymco would be jealous.

    Best Regards,
    Paul

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