English
Language : 

MC68HC812A4 Datasheet, PDF (283/342 Pages) Motorola, Inc – 16-bit device composed of standard on-chip peripheral modules connected by an intermodule bus. Modules include
Serial Peripheral Interface (SPI)
Synchronous Character Transmission using the SPI
; ----------------------------------------------------------------------
;*
SUBROUTINE INIT:
; ----------------------------------------------------------------------
INIT:
BSET PORTS,#$80
; SET SS Line High to prevent glitch
MOVB #$E0,DDRS
;
; Configure PORT S input/ouput levels
; MOSI, SCK, SS* = ouput, MISO=Input
MOVB #$07,SP0BR
; Select serial clock baud rate < 100 KHz
MOVB #$12,SP0CR1
; Configure SPI(SP0CR1): No SPI interrupts,
;
; MSTR=1, CPOL=0, CPHA=0
MOVB #$08,SP0CR2
; Config. PORTS output drivers to operate normally,
;
; and with active pull-up devices.
LDX #DATA
; Use X register as pointer to first character
LDAA SP0SR
LDAA SP0DR
; 1st step to clear SPIF Flag, Read SP0SR
; 2nd step to clear SPIF Flag, Access SP0DR
BSET SP0CR1,#$40
; Enable the SPI (SPE=1)
RTS
; Return from subroutine
; ----------------------------------------------------------------------
;*
TRANSMIT SUBROUTINE
; ----------------------------------------------------------------------
TRANSMIT:
LDAA 1,X+
; Load Acc. with "NEW" character to send, Inc X
BEQ DONE
; Detect if last character(0) has been transmitted
;
; If last char. branch to DONE, else
BCLR PORTS,#$80
; Assert SS Line to start X-misssion.
STAA SP0DR
; Load Data into Data Reg.,X-mit.
;
; it is also the 2nd step to clear SPIF flag.
FLAG: BRCLR SP0SR,#$80,FLAG ;Wait for flag.
BSET PORTS,#$80
; Disassert SS Line.
BRA TRANSMIT
; Continue sending characters, Branch to TRANSMIT.
DONE: RTS
; Return from subroutine
; ----------------------------------------------------------------------
; TABLE OF DATA TO BE TRANSMITTED
; ----------------------------------------------------------------------
DATA: DC.B 'Motorola'
DC.B $0D,$0A
; Return (cr) ,Line Feed (LF)
EOT: DC.B $00
; Byte used to test end of data = EOT
END
; End of program
Advance Information
MOTOROLA
Serial Peripheral Interface (SPI)
MC68HC812A4 — Rev. 3.0
283