i have a problem with interrupt with chip 16f84a i tried to run the follow procedure with pic simulator
;Chip Settings
#chip 16F84A,4
#config OSC=XT;
;Defines (Constants)
#define Switch PORTB.4
#define Led PORTB.1
;Variables
Dim RCsignal As byte;
;Interrupt Handlers
On Interrupt PORTBChange Call measure
DummyRead = PORTB
set RBIF off
InitTimer0 Osc, PS0_1/8
Dir Switch In
Dir Led Out
RCsignal = 0
Start:
set led off
If RCsignal <> 0 Then
Set Led On
else
set led off
End If
Goto start
Sub measure
Wait Until switch = 1
ClearTimer 0
Wait Until switch = 0
RCsignal = TMR0
DummyRead = PORTB ' Clear the mismatch
End Sub
this was suggested me by nobody but really i cannot understand why won't work
i tried also another simple routine but nothing
simple routine :
;Chip Settings
#chip 16F84A,4
;Interrupt Handlers
On Interrupt PORTBChange Call ledon
Dir PORTB.4 In
Dir PORTA.1 Out
start:
Set PORTA.1 On
Wait 4 ms
Set PORTA.1 Off
Wait 4 ms
Goto start
Sub ledon
Set PORTA.1 On
End Sub
can any one help
many thanks
salvo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi ,
In the second sample delays are too short to see any brigthness change of led . Try with wait 500 ms or wait 1 s
In the first sample you ask waiting switch=1 at each interruptportBchange but if the program calls this sub it's because portB.4 have already toggled .
GC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
in the second sample i can see on the simulator the led flashing but it does not stay on.
i tryed also to put the oscilloscope and set the simulation speed very slowly, but i cannot see the interrupt
i didn't try with the real pic circuit because in my garage now the termometer show -1 °C
so my hand get iced if i start work on my pic programmer so i'm trying with simulator
if is not disturbing you it is possible to have a sample of interrupt program on this 16f84a?
just a switch that can generate an interrupt to set an output on just to see if the simulator is working properly
or gcbasic do some error on compiling
i tryed any possible sample but with no luck…
thx for your support
ciao
salvo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
The led never stays on because after each interrupt the program returns to the loop .
Then the led is flashing on and off every 4 mS
In the sub interrupt "ledon" you can write "wait X s" after "set portA.1 on" .
X =1 or every value you want
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
This code can work but if interrupt occurs just after wait 3 s the program 'll return to start and portA.1 'll reset again instantaneously so you cannot see LED flashing on
It'll be better to put "Wait 3 s" just after start:
On PIC16F84 interrupts occur only on PortB.4 to PortB.7 , so i think your code is correct . You must read PIC16F84A datasheet , PortB functions Table 5-3 and chapter 5-3
So you can assume a led on portB.0 to portB.3
But perhaps have you omitted to write the config OSC : "#config OSC=XT" ?
regards
GC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi to all
i tryed this under your advice and try to put 3s of delay everywere, but it is so strange nothing happen…
here the routine
;Chip Settings
#chip 16F84A,4
#config OSC=XT
;Interrupt Handlers
On Interrupt PORTBChange Call ledon
Dir PORTB.4 In ;Assume a switch
Dir PORTA.1 Out ;Assume a LED and on PORTB will not cause interrupt?
start:
wait 3 s
Set PORTA.1 Off
Wait 3 s
Goto start
Sub ledon
Set PORTA.1 On
wait 3 s
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry on the OSC, but I just cut and pasted his program. My gold was the make it where the LED will stay off all the time and on with the switch press (via interrupt) until up to 3 seconds and go back out so they can see the compiler is working. Or the sim.emulator they are use.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi , I just tried to simulate jour code with Real Pic Simulator and it works fine .
Differents times of ON and OFF depend of push- button.
I tried this code ,slightly modified :
;Chip Settings
#chip 16F84A,4
#config OSC=XT
;Interrupt Handlers
On Interrupt PORTBChange Call ledon
Dir PORTB.4 In ;Assume a switch
Dir PORTA.1 Out ;Assume a LED and on PORTB will not cause interrupt?
do
wait 1 s
Set PORTA.1 Off
wait 1 s
loop
Sub ledon
Set PORTA.1 On
End Sub
GC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi ,
I use 1.3.0.0 version . I tried again and the result is OK .
But you must choose 16F84A device before loading hex file .
In visual mode you choose button on portB.4 and led on portA.1
When you push button , led flash on and off . But the delays the led stays on an off are each time different as I explained you before.
Good luck
GC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi!
this is what i did….
16f84a before to select the Hex file;
push button normally open on port B4 and a led on port a1
the simulator does not see any interrupt…
may be the version is too old and need to buy the new one…
let's try the demo so i can see if it work
many thanks!
ciao
salvo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hello
i have a problem with interrupt with chip 16f84a i tried to run the follow procedure with pic simulator
;Chip Settings
#chip 16F84A,4
#config OSC=XT;
;Defines (Constants)
#define Switch PORTB.4
#define Led PORTB.1
;Variables
Dim RCsignal As byte;
;Interrupt Handlers
On Interrupt PORTBChange Call measure
DummyRead = PORTB
set RBIF off
InitTimer0 Osc, PS0_1/8
Dir Switch In
Dir Led Out
RCsignal = 0
Start:
set led off
If RCsignal <> 0 Then
Set Led On
else
set led off
End If
Goto start
Sub measure
Wait Until switch = 1
ClearTimer 0
Wait Until switch = 0
RCsignal = TMR0
DummyRead = PORTB ' Clear the mismatch
End Sub
this was suggested me by nobody but really i cannot understand why won't work
i tried also another simple routine but nothing
simple routine :
;Chip Settings
#chip 16F84A,4
;Interrupt Handlers
On Interrupt PORTBChange Call ledon
Dir PORTB.4 In
Dir PORTA.1 Out
start:
Set PORTA.1 On
Wait 4 ms
Set PORTA.1 Off
Wait 4 ms
Goto start
Sub ledon
Set PORTA.1 On
End Sub
can any one help
many thanks
salvo
Hi ,
In the second sample delays are too short to see any brigthness change of led . Try with wait 500 ms or wait 1 s
In the first sample you ask waiting switch=1 at each interruptportBchange but if the program calls this sub it's because portB.4 have already toggled .
GC
hello gcha44
in the second sample i can see on the simulator the led flashing but it does not stay on.
i tryed also to put the oscilloscope and set the simulation speed very slowly, but i cannot see the interrupt
i didn't try with the real pic circuit because in my garage now the termometer show -1 °C
so my hand get iced if i start work on my pic programmer so i'm trying with simulator
if is not disturbing you it is possible to have a sample of interrupt program on this 16f84a?
just a switch that can generate an interrupt to set an output on just to see if the simulator is working properly
or gcbasic do some error on compiling
i tryed any possible sample but with no luck…
thx for your support
ciao
salvo
Hi,
The led never stays on because after each interrupt the program returns to the loop .
Then the led is flashing on and off every 4 mS
In the sub interrupt "ledon" you can write "wait X s" after "set portA.1 on" .
X =1 or every value you want
Does this below work?? I would have to look more into the portbchange since you have the in and out both on port B
#chip 16F84A,4
On Interrupt PORTBChange Call ledon
Dir PORTB.4 In ;Assume a switch
Dir PORTA.1 Out ;Assume a LED and on PORTB will not cause interrupt?
start:
Set PORTA.1 Off
Wait 3 s
Goto start
Sub ledon
Set PORTA.1 On
End Sub
Hi,
This code can work but if interrupt occurs just after wait 3 s the program 'll return to start and portA.1 'll reset again instantaneously so you cannot see LED flashing on
It'll be better to put "Wait 3 s" just after start:
On PIC16F84 interrupts occur only on PortB.4 to PortB.7 , so i think your code is correct . You must read PIC16F84A datasheet , PortB functions Table 5-3 and chapter 5-3
So you can assume a led on portB.0 to portB.3
But perhaps have you omitted to write the config OSC : "#config OSC=XT" ?
regards
GC
hi to all
i tryed this under your advice and try to put 3s of delay everywere, but it is so strange nothing happen…
here the routine
;Chip Settings
#chip 16F84A,4
#config OSC=XT
;Interrupt Handlers
On Interrupt PORTBChange Call ledon
Dir PORTB.4 In ;Assume a switch
Dir PORTA.1 Out ;Assume a LED and on PORTB will not cause interrupt?
start:
wait 3 s
Set PORTA.1 Off
Wait 3 s
Goto start
Sub ledon
Set PORTA.1 On
wait 3 s
End Sub
Sorry on the OSC, but I just cut and pasted his program. My gold was the make it where the LED will stay off all the time and on with the switch press (via interrupt) until up to 3 seconds and go back out so they can see the compiler is working. Or the sim.emulator they are use.
hello nobody how are you???
if i understand good i have to program it with the real pic 16f84a?
you think simulator can have trouble?
thanks
Salvo.
I just modded your code to what I would try first. What simulator do you use, I will compile it and test it for you. If you try it add the OSC type..
Somar
i use pic simulator
if you google it you can find it fast
they allow you to test some progect for 30 day than you have to buy it
is very usefull.
salvo
Hi , I just tried to simulate jour code with Real Pic Simulator and it works fine .
Differents times of ON and OFF depend of push- button.
I tried this code ,slightly modified :
;Chip Settings
#chip 16F84A,4
#config OSC=XT
;Interrupt Handlers
On Interrupt PORTBChange Call ledon
Dir PORTB.4 In ;Assume a switch
Dir PORTA.1 Out ;Assume a LED and on PORTB will not cause interrupt?
do
wait 1 s
Set PORTA.1 Off
wait 1 s
loop
Sub ledon
Set PORTA.1 On
End Sub
GC
hi
i tryed your routine with real pic simulator 1.1 but it does not work
now i'm wondering wich version did you use?
thx
salvo
Hi ,
I use 1.3.0.0 version . I tried again and the result is OK .
But you must choose 16F84A device before loading hex file .
In visual mode you choose button on portB.4 and led on portA.1
When you push button , led flash on and off . But the delays the led stays on an off are each time different as I explained you before.
Good luck
GC
hi!
this is what i did….
16f84a before to select the Hex file;
push button normally open on port B4 and a led on port a1
the simulator does not see any interrupt…
may be the version is too old and need to buy the new one…
let's try the demo so i can see if it work
many thanks!
ciao
salvo