User`s manual
MOTOROLA MC68332TUT/D
38
4.4 Configuring the Queued Serial Module
The queued serial module (QSM) is divided into two submodules: the serial communications interface (SCI)
and the queued serial peripheral interface (QSPI). The following sections give basic examples of QSM con-
figuration. See the
QSM Reference Manual
for more detailed information.
4.4.1 Configuring the SCI
The following example program can be assembled with IASM32. It prints a five-character message to the
screen. Do the following before running this program:
1. Connect an RS-232 cable from the PC serial port to the target board.
2. When using ICD32, set the serial communications protocol for the COM port being used, 9600 baud,
no parity, 8 data bits, and 1 stop bit. For example, when using COM 2, type in the command: serial
2 9600 n 8 1
3. When using ICD32, enable the serial communications by typing: serialon
4. Load and run the program.
* SCI INITIALIZATION:
SCCR0 EQU $FFFC08
SCCR1 EQU $FFFC0A
SCSR EQU $FFFC0C
SCDR EQU $FFFC0E
SYNCR EQU $FFFA04
SYPCR EQU $FFFA21
ORG $400 ;begin program at $400, immediately after
;the exception table
INIT_SIM
MOVE.B #$7F,(SYNCR).L ;increase clock speed
CLR.B (SYPCR).L ;disable software watchdog
INIT_SCI
MOVE.W #$0037,(SCCR0).L ;set the SCI baud rate to 9600
MOVE.W #$000C,(SCCR1).L ;enable the receiver and transmitter
PRINT
LEA (MESSAGE).L,A0 ;load the effective address of the message
;to be printed into address register A0.
* The next two commands load the effective address of the last character
* of the message into address register A1.
MOVE.L A0,A1
ADDA.L #$5,A1
* The next three commands check to see if the transmit data register is empty
* by looking at the TDRE bit in the SCI status register (SCSR). If the TDRE bit
* is zero, then there is data in register TDR that has not yet been sent to the
* transmit serial shifter. If the TDRE bit is one, then the transfer has
* occurred, and a new character may be written to register TDR. Thus, this
* sequence of code loops until the TDRE bit is one.
LOOP
MOVE.W (SCSR).L,D0
ANDI.W #$0100,D0
BEQ LOOP
MOVE.B (A0)+,D0 ;move the current letter of the message
;into D0. Then, increment A0 to point to
;the next letter
MOVE.W D0,(SCDR).L ;transfer the current letter to SCDR
CMPA.L A1,A0 ;check to see if at the end of the message
BNE LOOP ;if not, print another character
FINISH
BRA FINISH ;stay here when done
MESSAGE
FCB '12345' ;“12345” will be printed