
MOTOROLA
8-16
SYNCHRONOUS SERIAL PERIPHERAL INTERFACE
M68HC11
REFERENCE MANUAL
* Register definitions for 68HCll registers (used for Ex 8-1 & 8-2)
PORTD
EQU
$1008
*
DDRD
EQU
$1009
SPCR
EQU
$1028
*
SPSR
EQU
$1029
*
SPDR
EQU
$102A
1008
Port D data register
" - , - ,SS* ,SCK ;MOSI,MISO,TxD ,RxD "
Port D data direction
SPI control register
"SPIE,SPE ,DWOM,MSTR;CPOL,CPHA,SPR1,SPR0"
SPI status register
"SPIF,WCOL, - ,MODF; - , - , - , - "
SPI data register; Read-Buffer; Write-Shifter
1009
1028
1029
102a
* RAM variables (DAx used by Ex 8-1 & 8-2, SPIx used only by 8-1)
DA1
EQU
$00
DA2
EQU
$01
DA3
EQU
$02
DA4
EQU
$03
DA5
EQU
$04
DA6
EQU
$05
* Upper 2 bits of DAx should be 0 but will be ignored.
SPI1
EQU
$06
SPI2
EQU
$07
SPI3
EQU
$08
SPI4
EQU
$09
SPI5
EQU
$0A
* NOTE: Upper 4 bits of SPI1 are unused extras but will be 0.
0000
0001
0002
0003
0004
0005
6-bit val for D/A ch 1 "-,-,15,14;13,12,11,10"
6-bit val for D/A ch 2 "-,-,25,24;23,22,21,20"
6-bit val for D/A ch 3 "-,-,35,34;33,32,31,30"
6-bit val for D/A ch 4 "-,-,45,44;43,42,41,40"
6-bit val for D/A ch 5 "-,-,55,54;53,52,51,50"
6-bit val for D/A ch 6 "-,-,65,64;63,62,61,60"
0006
0007
0008
0009
000a
SPI packed byte 1 "--,--,--,--;65,64,63,62"
SPI packed byte 2 "61,60,55,54;53,52,51,50"
SPI packed byte 3 "45,44,43,42;41,40,35,34"
SPI packed byte 4 "33,32,31,30;25,24,23,22"
SPI packed byte 5 "21,20,15,14;13,12,11,10"
Figure 8-8 Register Definitions and RAM Variables for Examples 8–1 and 8–2
8.7.1 Example 8–1: On-Chip SPI Driving an MC144110 D/A
In this example, software must reformat (pack) the six 6-bit data values into five 8-bit
words, which can then be transferred to the MC144110 D/A using the on-chip SPI.
Fig-
ure 8-9
is the software listing for the Example 8–1 routines.
In the Example 8–1 setup, the MCU is running at 2-MHz E-clock frequency. To meet
the timing requirements of the MC144110 D/A, the slowest SPI clock rate (E
÷
32) is
used.
Figure 8-10
shows a detailed analysis of important timing parameters. These
timing details are derived from knowledge of the cycle-by-cycle activity of software in-
structions and detailed SPI system timing. This timing analysis depicts the strong in-
terdependence of software and hardware in MCU systems.
8.7.2 Example 8–2: Software SPI Driving an MC144110 D/A
Sometimes it is easier and/or more efficient to use software to emulate an SPI to allow
even more flexibility than the on-chip SPI system allows (e.g., odd word lengths). As
Example 8–2 shows, it is not necessarily difficult to manipulate I/O pins to create an
SPI-like interface. In this example, a software SPI allows 6-bit transfers so the six D/A
values can be used without any packing or reformatting (needed in the previous ex-
ample).
Figure 8-11
is the software listing for Example 8–2.