I cannot get SPI0 to work on LPC1769

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

I cannot get SPI0 to work on LPC1769

320 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Fklein23 on Thu Oct 23 07:01:57 MST 2014
I have wrestled with this channel for two weeks and am ready to give up.
I have a LPC1769 acting as SPI master and an LPC811 as slave.  The LPC811 code has worked in conjunction with a Windows based master, so I am confident that it is working OK and have concentrated on the 1769 code.

I tried both the polled and interrupt examples provided by NXP and could get neither to work at all (and was very frustrated by the degree of effort required to decipher the requirements for include files to just get the example code to compile).

So I rolled my own and immediately got successful interrupt service and saw the SSEL go low at the beginning of the write cycle and high at the end. I also noted that MISO went low immediately upon SSEL going low and went high several usecs after SSEL went high.

But the problem is that MOSI doesn't work at all. The best I can get is that it shows a weak "echo" of the clock, and never goes very far below 3 V.
As a result, my Saleae protocol analyzer shows MOSI being flat and high. The oscilloscope traces shown in the attached file show the true story.
I have tried every imaginable variation (PINMODE=pullup, pulldown, float, repeater; SPCR bit2=0, or bit2=1 and bits 11:8=0b100, etc.)  of the setup for this device and the results always look just like the attached oscope screenshot.

In the picture, the traces are as follows:
1. (yel) MOSI0
2. (BLU) MISO0
3. (MAG) SSEL0
4. (GRN) SCK0

I also included a Saleae screenshot of the same transaction.
In each of my experiments, I have tried to transmit the character, 'c'. So the MOSI signal should NOT look like a copy of the SCK signal.

Here is one of my setup variations:
I am using P0.15 through P0.18:
        LPC_SC->PCONP |= 0x1000;                         // SPI CLK ON
LPC_PINCON->PINSEL0 |= 0xC0000000;       // P0.15=SCK
LPC_PINCON->PINSEL1 |= 0x28;                   //
LPC_PINCON->PINMODE0 &= 0x0;    /// set all for pullup
        LPC_PINCON->PINMODE1 &= 0x0;
LPC_PINCON->PINMODE1 |= 3;        // SSEL = pulldown
LPC_GPIO0->FIODIR |= 0x10000 ;    // SSEL is output;
LPC_SPI->SPCR |= 0xF8;

I also tried this for FIODIR:
LPC_GPIO0->FIODIR |= 0x58000 ;    // MOSI0|SSEL0|SCK all set to 1 = output
and this for PINSEL0:
        LPC_PINCON->PINSEL0 |= 0x80000000;       // P0.15=SCK0
LPC_PINCON->PINSEL1 |= 0x3c ;

I reasoned that MOSI looked like it was geting pulled up with no problem, but couldn't get pulled down, so I tried
LPC_PINCON->PINMODE1 |= 3;        // SSEL =pulldown, MOSI=pullup
        LPC_PINCON->PINMODE1 |= 0xC3;  // SSEL =pulldown, MOSI=pulldown
        LPC_PINCON->PINMODE1 |= 0x43;  // SSEL =pulldown, MOSI=repeater
None of these made any difference.

FYI: I am using a 12 MHz clock and the SPI SCK is divided down by 4. The SCK on the scope is 3 MHz.

Suggestions?
Labels (1)
0 Kudos
2 Replies

283 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Fklein23 on Thu Oct 23 09:05:36 MST 2014
I found my problem.
In PINSEL1, I use the binary pattern, '10' to select MOSI0, MISO0, SSEL0 and SCK0 for P0.18 through P0.15
I changed the patterns to '11' and lo and behold, it now works!!!!!
I didn't think MOSI versus MOSI0 made any difference.
Someday I will figure out what the difference between SPI on an SSP port and just plain SPI is.
Thanks - Frank
0 Kudos

283 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Thu Oct 23 07:55:43 MST 2014

Quote: Fklein23
Suggestions?



Hardware check  :)

Disconnect slave, write a loop and check clock and MOSI...
0 Kudos