Bicycle speedometer (write not working continue)
Whell, I started e anew post because the last one was too large.
Ok, I finally got a program that seems to works fine and with a 4mhz osc.
The timer is set to 63ms, and it count it fourth times, so I get 250ms.
Here is the code, It has basic interrupts, but I'm trying to implement them in assembler. What do you think?
define osc 4
TRISA = %00000000
TRISB = %00000001
intcon = 0
clear
num var byte
x var word
pulsos var byte
cuenta var byte
velocidad var word
timer con 9
goto start
on interrupt goto tiempo
start:
OPTION_REG = %10000111
INTCON = %10100000
goto main
main:
if intcon.1 = 1 then
pulsos = pulsos + 1 ; count number of pulses on rb0
intcon.1 = 0
endif
if cuenta = 4 then
cuenta = 0
velocidad = pulsos * 4 * 100 ; meters/hour calc and km/h conversion rutine
velocidad = velocidad / 25
velocidad = velocidad * 36
velocidad = velocidad / 10
x = velocidad
pulsos = 0
endif
num = x dig 0 ; multiplexed display rutine using a 4511
porta = num
high portb.4
pause 3
low portb.4
num = x dig 1
porta = num
high portb.5
pause 3
low portb.5
num = x dig 2
porta = num
high portb.6
pause 3
low portb.6
goto main
disable
tiempo:
cuenta = cuenta + 1 ; counts number of times the timer
; interrupt activates
TMR0 = timer
INTCON.2 = 0
resume
enable