14-6
Seiko Epson Corporation
S1C31D50 TECHNICAL MANUAL
(Rev. 1.00)
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” chapte
r.)
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)
14.5.2.
Data Transmission in Master Mode
A data sending procedure and operations in master mode are shown below. Figures 14.5.2.1 and
14.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 SPIA_
n
INTF.TBEIF bit is set to 1 (transmit buffer empty).
3.
Write transmit data to the SPIA_
n
TXD register.
4.
Wait for an SPIA interrupt when using the interrupt.
5.
Repeat Steps 2 to 4 (or 2 and 3) until the end of transmit data.
6.
Negate the slave select signal by controlling the general-purpose output port (if necessary).
Data sending operations
SPIA Ch.
n
starts data sending operations when transmit data is written to the SPIA_
n
TXD register.
The transmit data in the SPIA_
n
TXD register is automatically transferred to the shift register and
the SPIA_
n
INTF.TBEIF bit is set to 1. If the SPIA_
n
INTE.TBEIE bit = 1 (transmit buffer empty
interrupt enabled), a transmit buffer empty interrupt occurs at the same time.
The SPICLK
n
pin outputs clocks of the number of the bits specified by the SPIA_
n
MOD.CHLN[3:0]
bits and the transmit data bits are output in sequence from the SDO
n
pin in sync with these clocks.
Even if the clock is being output from the SPICLK
n
pin, the next transmit data can be written to
the SPIA_
n
TXD register after making sure the SPIA_
n
INTF.TBEIF bit is set to 1.
If transmit data has not been written to the SPIA_
n
TXD register after the last clock is output from
the SPI- CLK
n
pin, the clock output halts and the SPIA_
n
INTF.TENDIF bit is set to 1. At the same time
SPIA issues an end-of-transmission interrupt request if the SPIA_
n
INTE.TENDIE bit = 1.
Содержание S1C31D50
Страница 461: ...25 1 Seiko Epson Corporation S1C31D50 TECHNICAL MANUAL Rev 1 00 25 Package TQFP12 48PIN ...
Страница 462: ...25 2 Seiko Epson Corporation S1C31D50 TECHNICAL MANUAL Rev 1 00 QFP13 64PIN ...
Страница 463: ...25 3 Seiko Epson Corporation S1C31D50 TECHNICAL MANUAL Rev 1 00 TQFP14 80PIN ...
Страница 464: ...25 4 Seiko Epson Corporation S1C31D50 TECHNICAL MANUAL Rev 1 00 QFP15 100PIN ...