1.4.2.1. Hardware/Software Interface
The assembly program reads the ADC assigning writing to the ADC control register (address $1030). The baud rate is set by writing to the baud rate register (address $102B).
There are 256 bytes of RAM at $0000-$00FF and 512 bytes of EEPROM at locations $B600-$B7FF. There is ROM at $E000-$FFFF. Locations $0036-$00FF are reserved. The following is the assembly program code list:
.OUTA EQU $FFB8 * output the contents of the A register
BAUDREG EQU $102B * address of the baud rate control register
SCSR EQU $102E * address of the SCI status register
SCDAT EQU $102F * address of the SCI data register
ADCTL EQU $1030 * address of the A/D control register
ADC2 EQU $1031 * address of the A/D result register 2
DELAY EQU $E2D9 * address of subroutine DELAY
NOTEON EQU $90 * noteon message
VEL EQU $40 * velocity (duration) of the midi note
ORG $0000 * start of the program
BEGIN LDAA #$20 * set BAUD rate to 31.25K
STAA BAUDREG * output the BAUD rate
REPEAT LDAA #noteon * A = 90 (noteon message)
OUT1 LDAB SCSR * B = SCI status
BITB #$80 * test bit7 of B
BEQ OUT1 * if bit7=1, i.e., SCI still busy, then wait
STAA SCDAT * else output A (noteon message)
NEWVOL LDAB #$02 * select ADC2
STAB ADCTL * by modifying ADCTL
LDAA ADC2 * then load an arbitrary number as NOTE NUMBER
LDAB #$08 * number of times calling DELAY = 9
WAIT JSR DELAY * call DELAY subroutine
DECB * B = B1
BNE WAIT * repeat calling DELAY for 9 times
PULB * pop B
PSHB * push B, used to get old note number
CBA * compare A and B
BEQ NEWVOL * if (A==B), then read another number
JSR .OUTA * if not equal, output the new note number
PULB * pop B
TAB * B = A
PSHB * push B, update the old note number
LDAA #VEL * note velocity = $40
JSR .OUTA * output note velocity
BRA REPEAT * repeat reading another number (a relative jump)
SWI * software interrupt
The OUTA subroutine outputs the A accumulator to the serial port.
[ Index | Main Paragraph ]