Specifications

52
The serial port requires having the baud rate set and also to enable the transmitter. It is
also adequate to enable the transceiver which accomplishes the same task. The baud
rate value is chosen and then a corresponding number is found from the baud rate
generation table in the HC12 data sheet. Loading accumulator A with the contents of
SC0DRL clears the flags inside that register and readies the serial port for use.
;****************SERIAL PORT**********************************************
; TO USE THE SERIAL PORT, SET BAUD RATE TO 19200
; BAUD. THE VALUE HERE IS A 16 BIT DIVISOR.
INITSC0 LDD #26 ; VALUE FROM BAUD RATE GENERATION
TABLE
STD SC0BDH
LDAA #$0C ; ENABLE TRANSCEIVER
STAA SC0CR2
LDAA SC0DRL ;CLEAR FLAGS
RTS
4.6.11 Serial Port Communications
Two simple subroutines were written for serial port communication. Although not
necessary to the correct functioning of the Mobile Manoeuvring Robots performance,
they provide an excellent debugging facility. Characters can be sent to a computer
screen to understand which parts of code are being run and hence follow the real time
branching and code order.
NEWLINE simply loads the ASCII value of a carriage return and uses the TXBYTE
subroutine to transmit it to the screen. This is followed by an ASCII line feed being
sent in a similar matter. On the computer screen this looks the same as hitting an enter
key in a text editor.
;***************SERIAL PORT WRITING COMMANDS******************************
; SEND A CARRIAGE RETURN AND LINE FEED TO SCREEN
NEWLINE LDAA #$0D ;LOAD CARRIAGE RETURN FOR ASCII
JSR TXBYTE ;TRANSMIT TO SCREEN