HT56R22/HT56R23/HT56R24/HT56R25/HT56R26
Serial Interface Function
The device contains a Serial Interface Function, which
includes both the four line SPI interface and the two line
I2C interface types, to allow an easy method of commu-
nication with external peripheral hardware. Having rela-
tively simple communication protocols, these serial
interface types allow the microcontroller to interface to
external SPI or I2C based hardware such as sensors,
Flash or EEPROM memory, etc. The SIM interface pins
are pin-shared with other I/O pins therefore the SIM in-
terface function must first be selected using a configura-
tion option. As both interface types share the same pins
and registers, the choice of whether the SPI or I2C type
is used is made using a bit in an internal register.
SPI Interface
The SPI interface is often used to communicate with ex-
ternal peripheral devices such as sensors, Flash or
EEPROM memory devices etc. Originally developed by
Motorola, the four line SPI interface is a synchronous
serial data interface that has a relatively simple commu-
nication protocol simplifying the programming require-
ments when communicating with external hardware
devices.
S P I M a s te r
SCK
SDO
SDI
SCS
S P I S la v e
SCK
SDI
SDO
SCS
SPI Master/Slave Connection
The communication is full duplex and operates as a
slave/master type, where the MCU can be either master
or slave. Although the SPI interface specification can
control multiple slave devices from a single master,
here, as only a single select pin, SCS, is provided only
one slave device can be connected to the SPI bus.
· SPI Interface Operation
The SPI interface is a full duplex synchronous serial
data link. It is a four line interface with pin names SDI,
SDO, SCK and SCS. Pins SDI and SDO are the Serial
Data Input and Serial Data Output lines, SCK is the
Serial Clock line and SCS is the Slave Select line. As
the SPI interface pins are pin-shared with normal I/O
pins and with the I2C function pins, the SPI interface
must first be enabled by selecting the SIM enable con-
figuration option and setting the correct bits in the
SIMCTL0/SIMCTL2 register. After the SPI configura-
tion option has been configured it can also be addi-
tionally disabled or enabled using the SIMEN bit in the
SIMCTL0 register. Communication between devices
connected to the SPI interface is carried out in a
slave/master mode with all data transfer initiations be-
ing implemented by the master. The Master also con-
trols the clock signal. As the device only contains a
single SCS pin only one slave device can be utilised.
The SPI function in this device offers the following fea-
tures:
¨ Full duplex synchronous data transfer
¨ Both Master and Slave modes
¨ LSB first or MSB first data transmission modes
¨ Transmission complete flag
¨ Rising or falling active clock edge
¨ WCOL and CSEN bit enabled or disable select
C K E G b it
C K P O L b it
S C K P in
fS Y S
fS U B
T im e r /E v e n t C o u n te r
S C S P in
C S E N b it
D a ta B u s
S IM D R
T x /R x S h ift R e g is te r
C lo c k
E d g e /P o la r ity
C o n tro l
C lo c k
S o u r c e S e le c t
B usy
S ta tu s
S D I P in
S D O P in
E n a b le /D is a b le
C o n fig u r a tio n
O p tio n
W C O L F la g
T R F F la g
C o n fig u r a tio n
O p tio n
E n a b le /D is a b le
SPI Block Diagram
Rev. 1.30
67
December 26, 2014