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?