![FTDI FT51A Скачать руководство пользователя страница 27](http://html1.mh-extra.com/html/ftdi/ft51a/ft51a_application-note_2341158027.webp)
Application Note
AN_289 FT51A Programming Guide
Version 1.0
Document Reference No.: FT_000962 Clearance No.: FTDI# 483
26
Copyright © 2015 Future Technology Devices International Limited
I/O
Address
Register Name
Description
0x50
SPI Master top level control register
0x51
Transmit data register
0x52
Receive data register
0x53
Interrupt Enable register
0x54
Interrupt Status register
0x55
Setup register
0x56
Clock divisor register
0x57
Data delay register
0x58
Slave select setup register
0x59
Transfer size setup register – lower
byte
0x5A
Transfer size setup register – upper
byte
0x5B
Transfer pending register
Table 2.22 SPI Master Register Addresses
The SPI Master module uses four wire interfaces: MOSI, MISO, CLK and SS#. There are four SS#
lines to control four different SPI Slave devices. The connection diagram is shown in Figure 2.1.
The main purpose is to send data from main memory to the attached SPI slave, and or to receive
data and send it to main memory. The SPI Master is controlled by the internal CPU using memory
mapped I/O registers. It operates from the main system clock, though sampling of input data and
transmission of output data is controlled by the SPI clock (CLK).
An SPI transfer can only be initiated by the SPI Master and begins with the slave-select signal
(SS#) being asserted by setting the
spi_ss_n
bit in SPI_MASTER_SETUP register. This is followed
by a data byte being clocked out with the master supplying CLK. Once the master has transferred
the desired number of bytes, it terminates the transaction by de-asserting slave-select. The SPI
Master can abort a transfer at any time by clearing the
spi_ss_n
bit to de-assert slave-select.
The CPU may control data transfer using the interrupts/status register
SPI_MASTER_INT
. Data
received by the SPI Master can be read from the
SPI_MASTER_RX_DATA
register, and data to be sent
out is written to the
SPI_MASTER_TX_DATA
register. In the case of data being sent from the Master,
there are bits indicating when there is space to write into the Tx holding register. Also, there is a
Tx-overrun bit (which is set when the user attempts to write data to a full Tx register), a bit
indicating whether the state machine is busy processing a transfer, and a Tx-done interrupt when
a byte has been sent. In the case of data received by the Master, the RX-full interrupt indicates
new data is available, and the Rx-overrun bit indicates that data has been received when the Rx
register was full.
The SPI Master module also supports transfers of predefined data packets. This performs
automatic control over SS#. The size of the transfer is specified in
SPI_TRANSFER_SIZE_U
and
SPI_TRANSFER_SIZE_L
registers,
and
a
completed
transfer
is
indicated
by
the