LPC1778 SPI Transmission

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

LPC1778 SPI Transmission

546 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lewy on Fri Oct 17 03:53:40 MST 2014
Hello,

I have encountered a complicated problem during boot up of my company's new PCB board. I hope someone had similar issue and can provide me with an advice.

Briefly:
I use SSP1 module in SPI mode. Here is setup code:
        PINSEL_ConfigPin(0, 7, 2);
PINSEL_ConfigPin(0, 8, 2);
PINSEL_ConfigPin(0, 9, 2);

       SSP_CFG_Type t_Config;

t_Config.Databit = SSP_DATABIT_8;
t_Config.CPHA = SSP_CPHA_FIRST;
t_Config.CPOL = SSP_CPOL_HI;
t_Config.Mode = SSP_MASTER_MODE;
t_Config.FrameFormat = SSP_FRAME_SPI;
t_Config.ClockRate = freq;

SSP_Init(LPC_SSP1, &t_Config);
SSP_Cmd(LPC_SSP1, ENABLE);


Because I had some communication issues with SD card thru SPI interface I have disconnected SCK0 MOSI0 MISO0 from everything except pull-ups (47k). I have shorted MOSI and MISO on mcu pins.
Here is the code I use to test correctness of received bytes:

        u32 freq = 15000000;
FsSpiInit(freq);
u8 data = 0;
const u8 dataPat = 0xaa;
for( ;; ) {

LPC_SSP1->DR = dataPat;
while (LPC_SSP1->SR & 0x10) 
               {}
data = LPC_SSP1->DR;

if (data != dataPat) {
Led2On();
RtosDelayMs(100);
Led2Off();
}
else {
Led1On();
RtosDelayMs(100);
Led1Off();
}

if (JP0GetState() == 0) {
if (freq == 30000000) {
freq = 5000000;
}
else {
freq += 5000000;
}
FsSpiInit(freq);
}
RtosDelayMs(5);
}


And here is the magic stuff:
When freq is equal or bellow 15MHz everything is fine but at 20MHz every bit change 0->1 produces 0 as received bit
etc: xF8->xF8, x8F->x87, xAA->x80, xFF->xFF, x7F->x3F, x67->x23
This is regular and happens all the time at 20MHz.
What is most interesting is that the signals on SCK MOSI and MISO all 100% all right. Amplitudes, setup and hold times are in specification range. I have checked each bit with oscilloscope at 10ns sec/div.
I have also checked the GND and 3V3  and the overshot and undershot are 0,2V which is all right I think. I tried to change mcu clock (120,108, 72, 60) as PCLK (120,60,108,54,18-the SCK was 18MHz and still the same error occurs)
I have 3 prototypes of the PCB and each behaves the same way. The LPC1778 are rev E.
I have lost whole week trying to find the answer. I will appreciate any help

Labels (1)
0 Kudos
1 Reply

471 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lewy on Mon Oct 27 02:14:11 MST 2014
I have an update to the issue.
It seems that the SSP1 module has problems receiving data at frequency over 15MHz in SPI mode. There is no issue with SSP0 module working with the same hardware configuration.
Has anyone experienced similar problems with SSP1?
The PCB is cut down to minimal configuration (power, crystal) with MOSI1 connected directly to MISO1.
0 Kudos