mg84fl54b Megawin Technology, mg84fl54b Datasheet - Page 43

no-image

mg84fl54b

Manufacturer Part Number
mg84fl54b
Description
Full-speed Usb Micro-controller
Manufacturer
Megawin Technology
Datasheet
16. Serial Peripheral Interface (SPI)
The device provides a high-speed serial communication interface, the SPI interface. SPI is a full-duplex, high-
speed and synchronous communication bus with two operation modes: Master mode and Slave mode. Up to 4
Mbps can be supported in either Master or Slave mode under the 12MHz system clock. A specially designed
Transmit Holding Register (THR) improves the transmit performance compared to the conventional SPI.
SPI Block Diagram
The SPI interface has four pins: MISO (P2.6), MOSI (P2.5), SPICLK (P2.7) and /SS (P2.4):
• SPICLK, MOSI and MISO are typically tied together between two or more SPI devices. Data flows from master
to slave on the MOSI pin (Master Out / Slave In) and flows from slave to master on the MISO pin (Master In /
Slave Out). The SPICLK signal is output in the master mode and is input in the slave mode. If the SPI system is
disabled, i.e., SPEN (SPCTL.6) = 0, these pins function as normal I/O pins.
• /SS is the optional slave select pin. In a typical configuration, an SPI master asserts one of its port pins to
select one SPI device as the current slave. An SPI slave device uses its SS pin to determine whether it is
selected. But if SPEN (SPCTL.6) = 0 or SSIG (SPCTL.7) = 1, the /SS pin is ignored.
Note that even if the SPI is configured as a master (MSTR = 1), it can still be converted to a slave by driving the
/SS pin low (if SSIG = 0). Should this happen, the SPIF bit (SPSTAT.7) will be set. See Section "Mode change
on /SS-pin".
The following special function registers are related to the SPI operation:
SPCTL (Address=85H, SPI Control Register)
MEGAWIN
SSIG
7
Fosc
SPEN
Clock Divider
6
16
48
12
24
96
4
8
6
DORD
5
Transmit Holding
SSIG
SPIF
Receive Data
Register
Buffer
MSTR
SPEN
THRE
4
MG84FL54B Data sheet
DORD
SPI block diagram
SPI Control
CPOL
MSTR
3
Output Shift
SYNCEN
Intput Shift
Register
Register
CPOL
CPHA
CPHA
CKOD
2
SSPOL
SPR1
SPR0
SPR2
I/O control
SPR1
1
SPSTAT
SPCTL
SPR0
0
(SPICLK)
(MISO)
(MOSI)
P2.6
P2.5
P2.7
P2.4
(SS)
43

Related parts for mg84fl54b