No. You can't have interrupts on any pin. Only pins that have some type of associated interrupt will cause a hardware interrupt.Can I have interupts on any pin ?
Testing inputs pins for high or low logic states is not a hardware interrupt.
No. You can't have interrupts on any pin. Only pins that have some type of associated interrupt will cause a hardware interrupt.Can I have interupts on any pin ?
Testing inputs pins for high or low logic states is not a hardware interrupt.
Last edited by Bruce; - 11th March 2010 at 00:50.
This is an example of what I mentioned earlier.
I'll call it FAKE INTERRUPT
It does have a latency of a little over a millisecond, but often it is plenty good enough to do what you need done. You can make the interrupt faster if you wish - but remember each time you enter/leave an interrupt, you are stealing quite a few processor cycles.
This code will check the status of any pin once per millisecond. It was written for an 18Fxxxx at 40Mhz. This example is checking the status of PORTC.0.
Code:Changed VAR BYTE OldPort VAR BYTE T0CON = %10001000 ; turn it on, 16 bits, no prescaler (osc/4) CLEAR '----------------- DT_INTS section ---------------------------- INCLUDE "DT_INTS-18.bas" INCLUDE "ReEnterPBP-18.bas" ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR0_INT, _FakeInt, PBP, yes endm INT_CREATE ENDASM Goto OverInt '------------------ Timer 0 interrupt handler----------------------------------- FakeInt: TMR0H = $D8 ; Preload depends on clk speed TMR0L = $F7 ; One millesecond timeout at 40Mhz. ; Always load HIGHBYTE FIRST Changed = PortC ^ OldPort IF Changed.0 = 1 THEN ; Pick your pin OldPort = PortC ;;;; Whatever you want to do when Port bit changes ENDIF @ INT_RETURN Overint: OldPort = PortC ; Init the var @ INT_ENABLE TMR0_INT NormalProgramLoop: Goto NormalProgramLoop END
Charles Linquist
Here's a schematic for 13 pins with interrupts using just two interrupt-on-change pins.
That's what reminded me I had the schematic...;o)At Post#3, I was trying to explain the same method.
WoW guys & gals, im overwhelmed with the response to this, thank you all very much.
Some of your ideas I have considdered, like a diode to the B0 pin, but I dont think that would work for my app, I need to have as many pins as input as possible which i think is about 33 at most on the 18f4550 (and 2 pins could fire at the same time), I will take a closer look at some of your suggestions on my day off work, it looks like some of it involves assembler which I dont get :-(, but Im sure I will pick something out of your ideas :-), Im just wondering if just polling the pins would be fast enough @ 20mhz, I'm gonna give all your ideas a try this w/end and see what works, thx
Reading the datasheet & understanding it are two different things.
Just an afterthought,
do all pic micro ports/pins have internal pull up resistors ?, i've been looking at the 18f4550 datasheet but cant tell ?, maybe i'm just stupid or tired lol :-)'
Thanks
Last edited by Bonxy; - 11th March 2010 at 22:25.
Reading the datasheet & understanding it are two different things.
No, internal pullups applys only to portB.
Al.
All progress began with an idea
Bookmarks