tur_bot,
Tested the program here on a 16F88.
Works as expected.
Only thing I can think of is maybe the RB6 LED is backwards, burnt-out, or hooked up wrong.
<br>
tur_bot,
Tested the program here on a 16F88.
Works as expected.
Only thing I can think of is maybe the RB6 LED is backwards, burnt-out, or hooked up wrong.
<br>
DT
hello
i woulk like to know how can i activate an interrupt digitally instead of using a switch.
because i wrote a program with need to jump to the interrupt when one of the 4 portb is low,
i.e. if portb.0=0 or portb.1=0 or portb.2=0 or portb.3 = 0 , the program should start the interrupt, i tried to use a subroutine to go that i.e. if portb.0=1 or portb.1=1 or .... gosub subroutine but it is very slow, i think that by using interrupt it will do the job.
can any one help me please. it s very urgent , it s for my project at uni and i have just a week to finish it.
thank you
Sounds to me like you should've started the 'project' for 'UNI' earlier...or maybe get a bit of help from the 'INSTRUCTOR' (if that's what they call them these days...I call them placeholders) or maybe even try some of your CLASSMATES.
Use another pin to trigger your 'PORTB.4' pin, write code to trigger that pin to trigger the other pin.
And no, I don't think this will solve your problem. If GOSUB'ing into your interrupt routine is slow, why would triggering an interrupt to go to the interrupt routine work any better? Your program is most likely hanging up in a loop somewhere or something similar making you think that it's not reacting fast enough, whereas triggering an interrupt in hardware may actually jump directly to that code.
Look for interrupt on change. But you may need to change your current hardware.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
my program is working fine but i just need to learn more about interrupt so i can make it better. by the way i started my project very early but not early enough (last summer).
about the small piece of code that i m using to learn about interrupt,I managed to improve my code and it s working but not as expected. the interrupt is activated on the falling edge but I want it to be activated on the rising edge.
i used a pull down resistor on the portb.0 and the main loop is running and when i connect a 5 volts to activate the interrupt nothing happens (everything stops ) but just when the 5 volts is taken off the interrupt runs for 2 second and the program is back to the main loop.
there is the code:
------------------------------------------------------------
@ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF
DEFINE OSC 4
OSCCON=%01101000
ANSEL=%00000000
CMCON=%00000111
OPTION_REG.6=1 'Trigger on rising edge
disable
clear
trisa = %11111111
trisb = %00000000
'Pause 500 ' Wait for startup
LOW PORTB.6
low portb.5
start:
goto loop
On Interrupt Goto UpdateCounter
INTCON = %10010000 'Enable INTE
disable
UpdateCounter:
high portb.6
Pause 2000 ' Wait 2 second
low portb.6
Pause 2000 ' Wait 2 second
low PORTB.5
INTCON.1=0 're-enable interrupts
resume
ENABLE
GOTO loop
loop:
high portb.5
Pause 2000 ' Wait 2 second
low portb.5
Pause 2000 ' Wait 2 second
low PORTB.6
Goto loop ' Do it forever
Disable
END
------------------------------
can you tell me what i did wrong , why the interrupt is not activated on the rising edge and how can I resolve it ??
thank you again for your advices ...
Last edited by tur_bot; - 1st April 2008 at 18:46.
there's a kinda mess in that
But if you want to trigger an INT0 interrupt, PORTB.0 must be set as an input.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
try this one
Code:@ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF DEFINE OSC 4 OSCCON=%01101000 ANSEL=%00000000 CMCON=%00000111 OPTION_REG.6=1 'Trigger on rising edge trisa = %11111111 trisb = %00000001 CounterA var word On Interrupt Goto UpdateCounter INTCON = %10010000 'Enable INTE PORTB=0 Pause 50 ' Wait for startup loop: TOGGLE PORTB.5 gosub dodelay Goto loop DoDelay: for countera=0 to 200 pause 1 next return disable UpdateCounter: low PORTB.5 high portb.6 Pause 2000 ' Wait 2 second low portb.6 INTCON.1=0 're-enable interrupts resume ENABLE
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
thank you very much , it was the trisb=0000001 command that resolved the problem. it works as expected but one more thing is not right, the portb.6 output 1.62 volts when the program goes through interrupt instead of giving a 5 volts output (a good logic one) as expected.
is it supposed to be like this?????
thank you again.
Last edited by tur_bot; - 2nd April 2008 at 12:00. Reason: last little problem
Bookmarks