# LPC1114: Setting up SPI

Discussion created by lpcware on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by gabrielh on Fri Apr 26 00:04:21 MST 2013
Hi,

This is my first time dabbing with SPI, so I'm not 100% comfortable with it.

I'm trying to initialize it, but I still have no relevant output on my pins, more specifically SCK.

This is the code I have so far:

void config_SSP(void)
{
LPC_SYSCON->PRESETCTRL |= (0x1<<0);
LPC_SYSCON->SYSAHBCLKCTRL |= (1UL << 11);

LPC_SYSCON->SSP0CLKDIV = 0x0a;

LPC_IOCON->PIO0_8 &= ~0x07; /* SSP I/O config */
LPC_IOCON->PIO0_8 |= 0x01; /* SSP MISO */
LPC_IOCON->PIO0_9 &= ~0x07;
LPC_IOCON->PIO0_9 |= 0x01; /* SSP MOSI */
LPC_IOCON->SCK_LOC = 0x02;
LPC_IOCON->PIO0_6 = 0x02;
LPC_IOCON->PIO0_2 &= ~0x07;
LPC_IOCON->PIO0_2 |= 0x01;

/* Set DSS data to 8-bit, Frame format SPI, CPOL = 0, CPHA = 0, and SCR is 7 */
LPC_SSP0->CR0 = 0x0707;

/* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */
LPC_SSP0->CPSR = 0x2;

/* Master mode */
LPC_SSP0->CR1 = 0;
}

Can someone please orient me on how to set this up correctly so I can at least see an SCK on the output pin? My slave broke recently so I can't do a full test with it until I get the replacement, but I still want to get ahead.

Thank you very much!