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
Bookmarks