Objective

LPC1768 SPI Block

The below block diagram shows the SPI input pins multiplexed with other GPIO pins.
The SPI pin can be enabled by configuring the corresponding PINSEL register to select SPI function.
When the SPI function is selected for that pin in the Pin Select register, other Digital signals are disconnected from the SPI input pins.

Port Pin Pin Number PINSEL_FUNC_0 PINSEL_FUNC_1 PINSEL_FUNC_2 PINSEL_FUNC_3
P0.15 47 GPIO TXD1 SCK0 SCK
P0.16 48 GPIO RXD1 SSEL0 SSEL
P0.17 46 GPIO CTS1 MISO0 MISO
P0.18 45 GPIO DCD1 MOSI0 MOSI

SPI Registers

Register Description
SPCR SPI Control Register : used to configure SPI
SPSR SPI status Register :
SPDR SPI Data Register : contains received data or data to be transmitted
SPCCR SPI Clock Counter Register : used to control master SCK frequency



SPI Register Configuration

Steps for using SPI

Initialize SPI

Send Data

Receive Data

Code

Example 1

Using Explore Embedded Libraries