Example description
This example describes how to use SSP in POLLING, INTERRUPT or DMA mode. It is needed to connect 2 hardware boards, one for Master and one for Slave.
SSP configuration:<br>
- CPHA = 0: data is sampled on the first clock edge of SCK.<br>
- CPOL = 0: SCK is active high.<br>
- Sample rate = 400kHz.<br>
- DSS = 8: 8 bits per transfer.<br>
- FRF= 0: SPI Frame format.<br>
After initialize transmit buffer, SPI master/slave will transfer a number of bytes
to SPI slave/master and receive data concurrently.<br>
After a transfer completed, receive and transmit buffer will be compared and
the result will be print out via UART port.<br>
This example supports 3 transfer modes: POLLING mode, INTERRUPT mode and DMA mode.<br>
- Connect UART port on the master board and slave board to COM ports on your PC.
- Configure terminal program on the PC per the above Serial display configuration
- Configure hardware, connect master board and slave board as below
- Build and run the example. Following guidance on terminals of master and slave to do test.
Special connection requirements
- Hitex A4 LPC1850 and LPC4350 boards
- PF_0 : X16 pin 43 - SCK0 master(slave) - connect to SCK slave(master) board
- PF_1 : X16 pin 46 - SEL0 master(slave) - connect to SEL slave(master) board
- PF_2 : X16 pin 45 - MISO0 master(slave) - connect to MISO slave(master) board
- PF_3 : X16 pin 44 - MOSI0 master(slave) - connect to MOSI slave(master) board
- Keil MCB1857 and MCB4357 boards
- PF_4 - SCK1 master(slave) - connect to SCK slave(master) board
- PF_5 - SSEL1 master(slave) - connect to SEL slave(master) board
- PF_6 - MISO1 master(slave) - connect to MISO slave(master) board
- PF_7 - MOSI1 master(slave) - connect to MOSI slave(master) board
- NGX Xplorer 1830 and 4330 boards
- CLK0 : J8 pin 7 - SCK1 master(slave) - connect to SCK slave(master) board
- P1_2 : J8 pin 8 - SSEL1 master(slave) - connect to SEL slave(master) board
- P1_3 : J8 pin 6 - MISO1 master(slave) - connect to MISO slave(master) board
- P1_4 : J8 pin 5 - MOSI1 master(slave) - connect to MOSI slave(master) board
Notes :
- Common ground must be connected together between two boards.
- The application default mode is Master mode. Press '1' on main menu to change Slave mode
Build procedures:
LPC18xx/43xx example quickstart for Keil uVision4
LPC18xx/43xx example quickstart for IAR EWARM
LPC18xx/43xx example quickstart for Code Red Xpresso
Supported boards and board setup:
Hitex 1850 evaluation boards
Hitex 4350 evaluation boards
Keil 1857 evaluation boards
Keil 4357 evaluation boards
NGX 1830 Xplorer boards
NGX 4330 Xplorer boards
Submitting LPCOpen issues:
Community support for LPCOpen
| #define BUFFER_SIZE (0x100) |
| #define SSP_DATA_BIT_NUM |
( |
|
databits | ) |
(databits+1) |
| #define SSP_DATA_BYTES |
( |
|
databits | ) |
(((databits) > SSP_BITS_8) ? 2:1) |
| #define SSP_DMA_SEL (0x33) |
| #define SSP_HI_BYTE_MSK |
( |
|
databits | ) |
((SSP_DATA_BYTES(databits) > 1) ? (0xFF>>(16-SSP_DATA_BIT_NUM(databits))):0) |
| #define SSP_INTERRUPT_SEL (0x32) |
| #define SSP_LO_BYTE_MSK |
( |
|
databits | ) |
((SSP_DATA_BYTES(databits) > 1) ? 0xFF:(0xFF>>(8-SSP_DATA_BIT_NUM(databits)))) |
| #define SSP_MASTER_MODE_SEL (0x31) |
| #define SSP_MODE_SEL (0x31) |
| #define SSP_POLLING_SEL (0x31) |
| #define SSP_SLAVE_MODE_SEL (0x32) |
| #define SSP_TRANSFER_MODE_SEL (0x32) |
| static void appSSPMainMenu |
( |
void |
| ) |
|
|
static |
| static void appSSPSelectModeMenu |
( |
void |
| ) |
|
|
static |
| static void appSSPTest |
( |
void |
| ) |
|
|
static |
| static void Buffer_Init |
( |
void |
| ) |
|
|
static |
| static uint8_t Buffer_Verify |
( |
void |
| ) |
|
|
static |
| void DMA_IRQHandler |
( |
void |
| ) |
|
DMA interrupt handler sub-routine. Set the waiting flag when transfer is successful.
- Returns
- Nothing
Definition at line 421 of file ssp.c.
Main routine for SSP example.
Main program body.
- Returns
- Nothing
Definition at line 436 of file ssp.c.
| void SSPIRQHANDLER |
( |
void |
| ) |
|
SSP interrupt handler sub-routine.
- Returns
- Nothing
Definition at line 399 of file ssp.c.
| volatile uint8_t isDmaRxfCompleted = 0 |
|
static |
| volatile uint8_t isDmaTxfCompleted = 0 |
|
static |
| volatile uint8_t isXferCompleted = 0 |
|
static |