How to get SPI working with the LPC4330

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get SPI working with the LPC4330

245 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kye on Sun Apr 07 19:00:44 MST 2013
Hello,

I'm trying to get the LPC4330 to output SPI data, but, I'm encountering problems getting the basic demo code working. I've download the following library http://lpcware.com/content/nxpfile/lpc4350apdlzip for controlling the SSP1 peripheral and I'm trying to get the SSP Master example code working found in the Examples/SSP sub directory in the peripheral library. I'm using the Keil version of the project.

The only changes I've made are to disable the debug output, use SSP1 instead of SSP0, and change the pin muxes for my particular setup. I am using a custom board to develop with, but, I've got the clock setup just like the LPC development board for the 4330.

I've attached the example code I'm using, there really isn't much to it. If anyone can point me in the right direction for what I am doing wrong it will be appreciated.

Also attached is the output wave form I am getting.

Thank you,
0 Kudos
2 Replies

226 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kye on Mon Apr 08 13:49:03 MST 2013
Well, I haven't even gotten that far. I can't even get it to output normal looking SPI data.
0 Kudos

226 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Mon Apr 08 05:52:32 MST 2013
Hi,

Are you sure that the default parameters set are appropriate for your interface?
In your code the default structure is used thus in lpc43xx_sssp.c
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [B]SSP_ConfigStructInit[/B]([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]SSP_CFG_Type[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *SSP_InitStruct)
{
SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]CPHA[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SSP_CPHA_FIRST;
SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]CPOL[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SSP_CPOL_HI;
SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]ClockRate[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 100000;
SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]Databit[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SSP_DATABIT_8;
SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]Mode[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SSP_MASTER_MODE;
SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]FrameFormat[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SSP_FRAME_SPI;
}

In my code I had to alter [COLOR=#0000c0]CPHA[/COLOR][SIZE=2] to match the SPI device used  thus[/SIZE]
[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [B]SSP_ConfigInit[/B]([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]SSP_CFG_Type[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *SSP_InitStruct)
{
SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]CPHA[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SSP_CPHA_SECOND; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//SSP_CPHA_FIRST[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]CPOL[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SSP_CPOL_HI;
SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]ClockRate[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 100000; [/SIZE]
[SIZE=2]SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]Databit[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SSP_DATABIT_8;
SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]Mode[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SSP_MASTER_MODE;
SSP_InitStruct->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]FrameFormat[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SSP_FRAME_SPI;
}

JohnR.[/LEFT]
[/SIZE]
0 Kudos