I made an addition to the code
The PortA.3 working properly, the PortA.4 but did not work always remains at a low level
What I make error, please help
Code:
@ device PIC16F84A, HS_OSC, WDT_OFF, PWRT_ON, PROTECT_OFF
TrisA = %00000000
PortA = %00000000
TrisB = %00000001
PortB = %00000000
Digit Var Byte
Time Var Word
Tcon Con 245
Time = Tcon
Imp Var Word
Imp = 0
RPM Var Word
RPM = 0
OPTION_REG = %10000011
TMR0=5
INTCON = %10110000
Pause 1000
' ------------------------- [ ---------- ] -------------------------
PortB = $7e '-
PortA.0 = 0: PortA.1 = 0: PortA.2 = 1
Pause 1000
PortB = $7e '-
PortA.0 = 0: PortA.1 = 1: PortA.2 = 0
Pause 1000
PortB = $7e '-
PortA.0 = 1: PortA.1 = 0: PortA.2 = 0
Pause 1000
' ------------------------- [ Interrupt ] -------------------------
On Interrupt Goto myint
' ------------------------- [ Main ] -------------------------
Main:
Digit = RPM Dig 0
PortA.0 = 1: PortA.1 = 0: PortA.2 = 0
GoSub Look
Pause 4
PortB = $FE
Digit = RPM Dig 1
PortA.0 = 0: PortA.1 = 1: PortA.2 = 0
GoSub Look
Pause 4
PortB = $FE
if RPM < 100 then
Pauseus 300
Goto Main
endif
Digit = RPM Dig 2
PortA.0 = 0: PortA.1 = 0: PortA.2 = 1
GoSub Look
Pause 4
PortB = $FE
' ----------------------- [ HIGH RPM ] -----------------------
if RPM >= 60 then
high PortA.3
else
low PortA.3
endif
if RPM >= 70 then
high PortA.4
else
low PortA.4
endif
Goto Main
' ----------------------- [-------------- ] -----------------------
Disable
Myint:
if intcon.1=1 then
Imp = Imp + 1
INTCON.1 = 0
endif
if intcon.2=1 then
Time = Time - 1
if Time = 0 then
Time = Tcon
RPM = Imp * 60 / 10
Imp = 0
endif
TMR0=5
intcon.2=0
endif
Resume
Enable
' --------------------------- [ ------- ] ---------------------------
Look:
LookUp Digit, [$80, $F2, $48, $60, $32, $24, $04, $F0, $00, $20], PortB
Return
' ------------------------- [ ----------- ] -------------------------
End
Bookmarks