14 SYNCHRONOUS SERIAL INTERFACE (SPIA)
S1C31D50/D51 TECHNICAL MANUAL
Seiko Epson Corporation
14-5
(Rev. 2.00)
14.4 Data Format
The SPIA data length can be selected from 2 bits to 16 bits by setting the SPIA_
n
MOD.CHLN[3:0] bits. The input/
output permutation is configurable to MSB first or LSB first using the SPIA_
n
MOD.LSBFST bit. Figure 14.4.1
shows a data format example when the SPIA_
n
MOD.CHLN[3:0] bits = 0x7, the SPIA_
n
MOD.CPOL bit = 0 and
the SPIA_
n
MOD.CPHA bit = 0.
Cycle No.
SPICLKn
SDOn
SDIn
SDOn
SDIn
1
2
3
4
5
6
7
8
Dw7
Dr7
Dw0
Dr0
Dw6
Dr6
Dw1
Dr1
Dw5
Dr5
Dw2
Dr2
Dw4
Dr4
Dw3
Dr3
Dw3
Dr3
Dw4
Dr4
Dw2
Dr2
Dw5
Dr5
Dw1
Dr1
Dw6
Dr6
Dw0
Dr0
Dw7
Dr7
SPIA_nMOD.
LSBFST bit
0
1
Writing Dw[7:0] to the SPIA_nTXD register
Loading Dr[7:0] to the SPIA_nRXD register
Figure 14.4.1 Data Format Selection Using the SPIA_nMOD.LSBFST Bit
(SPIA_nMOD.CHLN[3:0] bits = 0x7, SPIA_nMOD.CPOL bit = 0, SPIA_nMOD.CPHA bit = 0)
14.5 Operations
14.5.1 Initialization
SPIA Ch.
n
should be initialized with the procedure shown below.
1. <Master mode only> Generate a clock by controlling the 16-bit timer and supply it to SPIA Ch.
n
.
2. Configure the following SPIA_
n
MOD register bits:
- SPIA_
n
MOD.PUEN bit
(Enable input pin pull-up/down)
- SPIA_
n
MOD.NOCLKDIV bit
(Select master mode operating clock)
- SPIA_
n
MOD.LSBFST bit
(Select MSB first/LSB first)
- SPIA_
n
MOD.CPHA bit
(Select clock phase)
- SPIA_
n
MOD.CPOL bit
(Select clock polarity)
- SPIA_
n
MOD.MST bit
(Select master/slave mode)
3. Assign the SPIA Ch.
n
input/output function to the ports. (Refer to the “I/O Ports” chapter.)
4. Set the following SPIA_
n
CTL register bits:
- Set the SPIA_
n
CTL.SFTRST bit to 1. (Execute software reset)
- Set the SPIA_
n
CTL.MODEN bit to 1. (Enable SPIA Ch.
n
operations)
5. Set the following bits when using the interrupt:
- Write 1 to the interrupt flags in the SPIA_
n
INTF register.
(Clear interrupt flags)
- Set the interrupt enable bits in the SPIA_
n
INTE register to 1. * (Enable interrupts)
*
The initial value of the SPIA_
n
INTF.TBEIF bit is 1, therefore, an interrupt will occur immediately after the
SPIA_
n
INTE.TBEIE bit is set to 1.
6. Configure the DMA controller and set the following SPIA control bits when using DMA transfer:
- Write 1 to the DMA transfer request enable bits
in the SPIA_
n
TBEDMAEN and SPIA_
n
RBFDMAEN registers. (Enable DMA transfer requests)