Data Format; Data Transmission In Master Mode - Epson S1C17F13 Technical Manual

Cmos 16-bit single chip microcontroller
Table of Contents

Advertisement

11.4

Data Format

The data length is fixed at eight bits in the SPI. The input/output permutation is configurable to MSB first or LSB
first using the SPInMOD.LSBFST bit. Figure 11.4.1 shows a data format example when the SPInMOD.CPOL bit =
0 and the SPInMOD.CPHA bit = 0.
Cycle No.
SPInMOD.
SPICLKn
LSBFST bit
SDOn
0
SDIn
SDOn
1
SDIn
Writing Dw[7:0] to the SPInTXD register
Figure 11.
11.5
Operations
11.5.1
Initialization
The SPI 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 the SPI Ch.n.
2. Configure the following SPInMOD register bits:
- SPInMOD.PUEN bit
- SPInMOD.NOCLKDIV bit
- SPInMOD.LSBFST bit
- SPInMOD.CPHA bit
- SPInMOD.CPOL bit
- SPInMOD.MST bit
3. Assign the SPI Ch.n input/output function to the ports. (Refer to the "I/O Ports" chapter.)
4. Set the following SPInCTL register bits:
- Set the SPInCTL.SFTRST bit to 1. (Execute software reset)
- Set the SPInCTL.MODEN bit to 1. (Enable SPI Ch.n operations)
5. Set the following bits when using the interrupt:
- Write 1 to the interrupt flags in the SPInINTF register.
- Set the interrupt enable bits in the SPInINTE register to 1. * (Enable interrupts)
* The initial value of the SPInINTF.TBEIF bit is 1, therefore, an interrupt will occur immediately after the
SPInINTE.TBEIE bit is set to 1.
11.5.2

Data Transmission in Master Mode

A data sending procedure and operations in master mode are shown below. Figures 11.5.2.1 and 11.5.2.2 show a
timing chart and a flowchart, respectively.
Data sending procedure
1. Assert the slave select signal by controlling the general-purpose output port (if necessary).
2. Check to see if the SPInINTF.TBEIF bit is set to 1 (transmit buffer empty).
3. Write transmit data to the SPInTXD register.
4. Wait for an SPI interrupt when using the interrupt.
S1C17F13 TeChniCal Manual
(Rev. 1.0)
1
2
3
Dw7
Dw6
Dw5
Dr7
Dr6
Dr5
Dw0
Dw1
Dw2
Dr0
Dr1
Dr2
4.1 Data Format Selection Using the SPI
(SPInMOD.CPOL bit = 0, SPInMOD.CPHA bit = 0)
(Enable input pin pull-up/down)
(Select master mode operating clock)
(Select MSB first/LSB first)
(Select clock phase)
(Select clock polarity)
(Select master/slave mode)
Seiko epson Corporation
11 SYNCHRONOUS SERIAL INTERFACE (SPI)
4
5
6
Dw4
Dw3
Dw2
Dr4
Dr3
Dr2
Dw3
Dw4
Dw5
Dr3
Dr4
Dr5
Loading Dr[7:0] to the SPInRXD register
nMOD.LSBFST Bit
(Clear interrupt flags)
7
8
Dw1
Dw0
Dr1
Dr0
Dw6
Dw7
Dr6
Dr7
11-5

Advertisement

Table of Contents
loading

Table of Contents