Specifications

48
SUBA #$01 ;IF MOTOR A IS FASTER THAN $C5
STAA PWDTY2 ;SLOW MOTOR A SLIGHTLY
BRA DONE ;EXIT
FASTB LDAA PWDTY0 ;|
ADDA #$01 ;|SPEED B UP ONE
STAA PWDTY0 ;|
BRA DONE
;--------------------------------------
B2FAST JSR NEWLINE ;CASE MOTOR B IS FASTER THAN A
LDAA #'b'
JSR TXBYTE ;TX BYTE THROUGH SERIAL (DEBUG)
LDAA PWDTY0 ;LDAA WITH SPEED OF MOTOR B
CMPA #$65 ; |
BMI FASTA ; | IF MOTOR B GOING TOO SLOW, SPD UP
A
SUBA #$01 ;|
STAA PWDTY0 ;|SLOW MOTOR B SLIGHTLY
BRA DONE
FASTA LDAA PWDTY2 ;|
ADDA #$01 ;| SPEED A UP BY ONE
STAA PWDTY2 ;|
DONE MOVB #$00, COUNT ;|
MOVB #$00, ODMA ;| CLEAR COUNTERS
MOVB #$00, ODMB ;|
RTS ;RETURN AND WAIT FOR NEXT COMPARE
4.6.8 KWGISR Key Wake Up Port G
This is the code written for the interrupt service routine which is responsible for
incrementing the odometer counters every time the microcontroller receives a signal
from the odometer sensors. Basically, when the interrupt port is triggered by a falling
edge on any port G pin (5v down to 0v), the code checks each connected pin (pins 0 and
1) to determine which sensor triggered the interrupt. If pin 0 triggered the interrupt then
it loads ODMA and adds 1, if it was pin 1 that triggered it loads ODMB and increments
it. If both pin 0 and 1 appear to not have triggered the interrupt then the subroutine will
simply exit and the main program will continue to run.