lpcware

LPC 1788 SSP(SPI)

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by shkang on Wed Nov 21 23:50:39 MST 2012
please help me.

Recently, I try to communicate with a sensor by LPC 1788 SSP(SPI).

During control the board. SSP is not working. But I don't know what is problem.

is it ok to control SPI Communication??? Am I miss somthing?

//-----------------------------------------------------------------------------

PINSEL_ConfigPin(PORT_0, 15, 2);
PINSEL_ConfigPin(PORT_0, 17, 2);
PINSEL_ConfigPin(PORT_0, 18, 2);
PINSEL_ConfigPin(PORT_1, 18, 0); // Frame Ready
PINSEL_ConfigPin(PORT_2, 21, 0); // LED
PINSEL_ConfigPin(PORT_2, 14, 0); // CS

GPIO_SetDir(PORT_1, _PORT(18), GPIO_DIRECTION_INPUT);
GPIO_SetDir(PORT_2, _PORT(21), GPIO_DIRECTION_OUTPUT);
GPIO_SetDir(PORT_2, _PORT(14), GPIO_DIRECTION_OUTPUT);

GPIO_ClearValue(PORT_2, _PORT(21));          // LED
GPIO_SetValue(PORT_2, _PORT(14));          // CS


// initialize SSP configuration structure to default
SSP_ConfigStructInit(&SSP_ConfigStruct);
// Initialize SSP peripheral with parameter given in structure above
SSP_Init(LPC_SSP, &SSP_ConfigStruct);
// Enable SSP peripheral
SSP_Cmd(LPC_SSP, ENABLE);


GPIO_ClearValue(PORT_2, _PORT(14));          // CS Low
GPIO_SetValue(PORT_2, _PORT(21));          // LED OFF
   
SSP_SendData(LPC_SSP,0x99);
data2[0] = SSP_ReceiveData(LPC_SSP);
SSP_SendData(LPC_SSP,0x02);
data2[1] = SSP_ReceiveData(LPC_SSP);
SSP_SendData(LPC_SSP,0x8F);
data2[2] = SSP_ReceiveData(LPC_SSP);

GPIO_SetValue(PORT_2, _PORT(14));          // CS High

Outcomes