Page 1 of 1

ECIO Interrupt

Posted: Fri Dec 16, 2011 3:24 pm
by frankmortensen
Hello.
I will have A0 = 0 when I switch B1 from low to high, with an interrupt function.
My little program works fine in the simulation, but in hardware it seems that it interrupts all the time without me touching port B.
I've tried to put B0 to B7 low without it helped.
I use a ECIO40P
What do I do wrong ?
video lys off.fcf
(6.5 KiB) Downloaded 301 times

Re: ECIO Interrupt

Posted: Fri Dec 16, 2011 3:48 pm
by Benj
Hello,

Sounds like your input might be floating. Are you pulling the input pin to VDD or VSS using a resistor when the switch is not pressed?

Re: ECIO Interrupt

Posted: Fri Dec 16, 2011 4:14 pm
by frankmortensen
yes I've tried to connect all port B directly to ground.
but it makes no difference.

Re: ECIO Interrupt

Posted: Tue Dec 20, 2011 2:40 pm
by frankmortensen
I found the solution myself.
when ecio get power from USB port, it will interrupt all the time even when the gate b1 is connected to ground.
but when it is powered from an external source, there are no problems.
I also had to move reactivating the interrupt from interupt routine to the main program if it was in interupt routine, the interrupt was activated, all the time.
I do not understand it but now it works.
Here are pictures of the new program.
main.jpg
main.jpg (29.06 KiB) Viewed 4985 times
interupt.jpg
interupt.jpg (14.26 KiB) Viewed 4985 times

Re: ECIO Interrupt

Posted: Tue Dec 20, 2011 2:56 pm
by Gary Freegard
Hi

I have created two new version for you. The first is the same as yours but without the disabling and re enabling the interrupt.
The other has the control of the output in the main loop, the interrupt just flips a variable between 0 and 255. In the main loop the program checks this variable , if 255 the output on, wait 3 sec , output off, set variable to 0.
When writing interrupts macros its best to keep them as small as possible and try to do everything in the main loop. In your program it isn’t so important but if you start developing it further you could encounter problems, due to the fact the interrupt is disabled on entry to the interrupt macro and is enabled on exit.

Merry Christmas
Gary

PS This works on USB powered ECIO

Re: ECIO Interrupt

Posted: Tue Dec 20, 2011 3:21 pm
by frankmortensen
Thank you,
but I think I have to stop interrupt while I pause, because it will not be triggered by a single pulse but of a whole series of pulses.
and only the rising edge at the first pulse I will trigger on until the break is gone.

Re: ECIO Interrupt

Posted: Tue Dec 20, 2011 4:25 pm
by Gary Freegard
Hi

The second program will ignore subsequent interrupts until the variable is set to 0.

Gary