Difference between revisions of "LPC1768: SPI Programming"
m |
m |
||
Line 19: | Line 19: | ||
=SPI Registers= | =SPI Registers= | ||
+ | |||
+ | {| class="wikitable" style="text-align:left; background-color:#ABCDEF;" | ||
+ | !Register || Description | ||
+ | |- | ||
+ | |SPCR|| Contains the recently received Data | ||
+ | |- | ||
+ | |SPSR|| Contains the data to be transmitted | ||
+ | |- | ||
+ | |SPDR|| FIFO Control Register | ||
+ | |- | ||
+ | |SPCCR|| Controls the UART frame formatting(Number of Data Bits, Stop bits) | ||
+ | |- | ||
+ | |DLL|| Least Significant Byte of the UART baud rate generator value. | ||
+ | |- | ||
+ | |DLM|| Most Significant Byte of the UART baud rate generator value. | ||
+ | |} | ||
+ | <br><br> | ||
+ | |||
=SPI Register Configuration= | =SPI Register Configuration= | ||
=Steps for using SPI= | =Steps for using SPI= |
Revision as of 19:03, 16 June 2015
Contents
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 | Contains the recently received Data |
SPSR | Contains the data to be transmitted |
SPDR | FIFO Control Register |
SPCCR | Controls the UART frame formatting(Number of Data Bits, Stop bits) |
DLL | Least Significant Byte of the UART baud rate generator value. |
DLM | Most Significant Byte of the UART baud rate generator value. |
SPI Register Configuration
Steps for using SPI
Initialize SPI
Send Data
Receive Data
Code
Example 1
Using Explore Embedded Libraries