Code:
DEFINE LOADER_USED 1
DEFINE USE_LFSR 1
Include "modedefs.bas" 'this is required for RS232 comms
ADCON1=7
' Assign variable names
DBGDSPL VAR PORTB.5 'Debug display port
CurrPuls var byte
PulseA var word
PulseB var word
PulseR var word
LastACnt Var word
LastBCnt Var word
LastRCnt var word
CurrSec var word
LastSec var word
IntCount var word
pause 10
trisb=%00000111
T0CON = %10000011 'Define Timer0 - 1:16
RCON.7 = 0
INTCON = %10110000 'Enable TMR0 & Pin B0-B2 interrupts
INTCON2= %10000000 'Falling Edge
INTCON3= %11011000
goto start
'---------------------------------------------------------Interrupt Code
Disable ' No interrupts past this point
myint:
if INTCON.1<>0 or INTCON3.0<>0 or INTCON3.1<>0 then 'Pulse Interrupt
IntCount=IntCount+1
if INTCON3.0=1 and INTCON.1=0 and INTCON3.1=0 then PulseA =PulseA +1
if INTCON3.0=0 and INTCON.1=1 and INTCON3.1=0 then PulseR =PulseR +1
if INTCON3.0=0 and INTCON.1=0 and INTCON3.1=1 then PulseB =PulseB +1
SerOut DbgDspl, N9600, [$1b,$2a,$80] 'turn on background lighting of debug display
SerOut DbgDspl, N9600, [$1b,$30]
SerOut DbgDspl, N9600, ["I:",#IntCount, " A:", #INTCON3.0, " R:", #INTCON.1, " B:", #INTCON3.1]
SerOut DbgDspl, N9600, [$1b,$32]
SerOut DbgDspl, N9600, ["A:", #PulseA, "R:", #PulseR, "B:", #PulseB, "S:", #CurrSec]
INTCON.1=0 : INTCON3.0=0 : INTCON3.1=0
endif
if INTCON.2=1 then 'timer overflow interrupt
CurrSec = CurrSec +1
TMR0H=11 : TMR0L=186 'set tmr0 cycle count to 3002 so overflows in 1.0 sec
'TMR0H=231 : TMR0L=147 'set tmr0 cycle count to 59283 so overflows in .1 sec
'TMR0H=253 : TMR0L=143 'set tmr0 cycle count to 64911 so overflows in .01 sec
INTCON.2 = 0
endif
Resume ' Return to where interrupt occured
Enable
'---------------------------------------------------------End of Interrupt code
Start:
PulseA=0 : PulseB=0 : PulseR=0 : CurrSec=0 : LastSec=0 : IntCount=0
LastACnt=0 : LastRCnt=0 : LastBCnt=0
SerOut DbgDspl, N9600, [$1b,$2a,$80] 'turn on background lighting of debug display
SerOut DbgDspl, N9600, [$1b,$30]
SerOut DbgDspl, N9600, ["Start "]
SerOut DbgDspl, N9600, [$1b,$32]
pause 10
On Interrupt Goto myint ' Define interrupt handler
Mainloop:
if PulseR<>LastRCnt or PulseA<>LastACnt or PulseB<>LastBCnt or CurrSec<>LastSec then
' SerOut DbgDspl, N9600, [$1b,$2a,$80] 'turn on background lighting of debug display
' SerOut DbgDspl, N9600, [$1b,$30]
' SerOut DbgDspl, N9600, ["I:",#IntCount, " A:", #INTCON3.0, " R:", #INTCON.1, " B:", #INTCON3.1]
' SerOut DbgDspl, N9600, [$1b,$32]
' SerOut DbgDspl, N9600, ["A:", #PulseA, "R:", #PulseR, "B:", #PulseB, "S:", #CurrSec]
endif
pauseus 1
GOTO Mainloop
end
My time estimate is based soley on the serout stuff. I was just taking a guess at the number of bytes sent at 9600 baud.
Bookmarks