
MOTOROLA
8-20
SYNCHRONOUS SERIAL PERIPHERAL INTERFACE
M68HC11
REFERENCE MANUAL
****************************************************************************
* Example 8-2
*
* This example program uses a software equivalent of the SPI to
* drive an MC144110 six channel D to A converter peripheral. The
* physical hookup is the same as that of the previous example to make
* comparisons easier.
*
* To try Ex 8-2, connect MC144110 to Port D pins on EVB, load
* program into EVB RAM, manually enter data for DA1 to DA6 and
* execute a GO to $CI00
****************************************************************************
*
*
*
*
*
*
*
*
*
*
c100
c100 8e cf ff
c103 86 2f
c105 b7 10 08
c108 86 38
c10a b7 10 09
c10d 86 04
ORG
LDS
LDAA
STAA
LDAA
STAA
LDAA
$C100
#$CFFF
#$2F
PORTD
#$38
DDRD
#$04
"SPIE,SPE,DWOM,MSTR;CPOL,CPHA,SPR1,SPR0"
SPCR
Make sure SPI off
[3]
[2]
[4]
[2]
[4]
[2]
INIT2
Top of C page RAM
-,-,1,0;1,1,1,1
PD5/SS*-Lo,PD4/SCK-Lo,PD3/MOSI-Hi
-,-,1,1;1,0,0,0
PD5, PD4, PD3 =Outs; Others =Ins
*
c10f b7 10 28
[4]
STAA
***
* Following two instructions call main routine for Ex 8-2
***
c112 8d 03
[6]
BSR
c114 7e e0 00
[3]
JMP
***
c117 3c
[4]
UPDAT2 PSHX
c118 18 3c
[5]
PSHY
c11a 36
[3]
PSHA
c11b 18 ce 00 05[4]
LDY
c11f ce 10 00
[3]
LDX
c122 86 20
[2]
TFRLP2 LDAA
c124 1d 08 20
[7]
BCLR
c127 01
[2]
NOP
c128 01
[2]
NOP
c129 1c 08 10
[7]
NXTBIT BSET
c12c 18 a5 00
[5]
BITA
c12f 27 05
[3]
BEQ
c131 1c 08 08
[7]
BSET
c134 20 05
[3]
BRA
c136 1d 08 08
[7]
ZBIT
BCLR
c139 20 00
[3]
BRA
c13b 1d 08 10
[7]
ENDBIT BCLR
c13e 44
[2]
LSRA
c13f 26 e8
[3]
BNE
c141 18 09
[4]
DEY
c143 18 8c ff ff[5]
CPY
c147 26 db
[3]
BNE
c149 1c 08 20
[7]
BSET
c14c 32
[4]
PULA
c14d 18 38
[6]
PULY
c14f 38
[5]
PULX
c150 39
[5]
RTS
UPDAT2
$E000
Xfer six 6 bit words to MC144110
Restart BUFFALO
Save X, Y and A
#DA6
#$1000
#$20
PORTD,X
Point at 1st D/A value to xfer.
Point at register area.
1st pntr to MSB of 6 bit data val
%00100000 PD5(SS*) Falling edge
Need more dly for MC144110 specs.
PORTD,X
0,Y
ZBIT
PORTD,X
ENDBIT
PORTD,X
ENDBIT
PORTD,X
%00010000 PD4(SCK) Rising edge
Test sense of bit to be sent
If zero skip around
%00001000 PD3(MOSI) Hi bit
%00001000 PD3(MOSI) Lo bit
Want Lo time to match Hi time
%00010000 PD4(SCK) Falling edge
Pointer to nxt lower bit position
Done if pointer shifted past LSB
Point at next value to send
Done yet
If not go back to top of loop
%00100000 PD5(SS*) Rising edge
Restore X, Y and A
NXTBIT
#DA1-1
TFRLP2
PORTD,X
** RETURN **
Figure 8-11 Example 8–2 Software Listing