Master Mode Operation; Master Mode Transmit Sequence; Figure 73. Hardware/Software Slave Select Management - STMicroelectronics ST72361 Auto Series Manual

8-bit mcu for automotive with flash or rom, 10-bit adc, 5 timers, spi, linsci
Table of Contents

Advertisement

Serial peripheral interface (SPI)

Figure 73. Hardware/software slave select management

14.3.3

Master mode operation

In master mode, the serial clock is output on the SCK pin. The clock frequency, polarity and
phase are configured by software (refer to the description of the SPICSR register).
Note: The idle state of SCK must correspond to the polarity selected in the SPICSR register
(by pulling up SCK if CPOL = 1 or pulling down SCK if CPOL = 0).
How to operate the SPI in master mode
To operate the SPI in master mode, perform the following steps in order:
1.
Write to the SPICR register:
Note: The slave must have the same CPOL and CPHA settings as the master.
2.
Write to the SPICSR register:
3.
Write to the SPICR register:
Note: MSTR and SPE bits remain set only if SS is high).
Caution:
If the SPICSR register is not written first, the SPICR register setting (MSTR bit) may be not
taken into account.
The transmit sequence begins when software writes a byte in the SPIDR register.
14.3.4

Master mode transmit sequence

When software writes to the SPIDR register, the data byte is loaded into the 8-bit shift
register and then shifted out serially to the MOSI pin most significant bit first.
When data transfer is complete:
The SPIF bit is set by hardware.
An interrupt request is generated if the SPIE bit is set and the interrupt mask in the
CCR register is cleared.
Clearing the SPIF bit is performed by the following software sequence:
1.
An access to the SPICSR register while the SPIF bit is set
2.
A read to the SPIDR register
Note:
While the SPIF bit is set, all writes to the SPIDR register are inhibited until the SPICSR
register is read.
146/279
SS external pin
Select the clock frequency by configuring the SPR[2:0] bits.
Select the clock polarity and clock phase by configuring the CPOL and CPHA bits.
Figure 74
shows the four possible configurations.
Either set the SSM bit and set the SSI bit or clear the SSM bit and tie the SS pin
high for the complete byte transmit sequence.
Set the MSTR and SPE bits
Doc ID 12468 Rev 3
SSM bit
SSI bit
1
SS internal
0
ST72361xx-Auto

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ST72361 Auto Series and is the answer not in the manual?

Table of Contents