NUC970 Technical Reference Manual
Publication Release Date: Dec. 15, 2015
- 541 -
Revision V1.30
NUC97
0
T
E
CHNIC
A
L
RE
F
E
RE
N
CE
MA
NUA
L
SPI Programming Example
5.19.5.4
If a device with following specifications:
Data bit latches on positive edge of serial clock
Data bit drives on negative edge of serial clock
Data is transferred with the MSB first
Only one byte transmits/receives in a transfer
Chip select signal is active low
Do following actions basically (Should refer to the specification of device for the detailed steps):
Write a divisor into DIVIDER to determine the frequency of serial clock.
Write in SSR, set ASS = 0, SS_LVL = 0 and SSR[0] or SSR[1] to 1 to activate the device you want to
access.
When transmit (write) data to device:
Write the data you want to transmit into Tx0[7:0].
When receive (read) data from device:
Write 0xFFFFFFFF into Tx0.
Write in CNTRL, set Rx_NEG = 0, Tx_NEG = 1, Tx_BIT_LEN = 0x08, Tx_NUM = 0x0, LSB = 0,
SLEEP = 0x0 and GO_BUSY = 1 to start the transfer.
–– Wait for interrupt (if IE = 1) or polling the GO_BUSY bit until it turns to 0 ––
Read out the received data from Rx0.
Go to 3) to continue data transfer or set SSR[0] or SSR[1] to 0 to inactivate the device.