LPC Link-2_SPI_No data in data register

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

LPC Link-2_SPI_No data in data register

1,937 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dark Star on Mon Aug 11 12:17:58 MST 2014
Im working with LPCXpresso and LPC Link-2 board (LPC4370). I wanted to poll SPI data (SSP1), but there is nothing else than a 0 in there. Also the RNE bit is never set. SPI is configuted as Slave. The signals from the master is o.k. (MOSI, SCLK, SEL).

My code:

Init:
/* P1.19 connected to SCL/SCLKSCU_MODE_FUNC1=SSP1 SCK1 */
Chip_SCU_PinMuxSet(0xF, 4, (SCU_PINIO_FAST | SCU_MODE_FUNC0));
/* P1.20 connected to nCSSCU_MODE_FUNC1=SSP1 SSEL1 */
Chip_SCU_PinMuxSet(0x1, 20, (SCU_PINIO_FAST | SCU_MODE_FUNC1));
/* P0.0 connected to SOSCU_MODE_FUNC1=SSP1 MISO1 */
Chip_SCU_PinMuxSet(0x1, 3, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC5));
/* P0.1 connected to nSISCU_MODE_FUNC2=SSP1 MOSI1 */
Chip_SCU_PinMuxSet(0x1, 4, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC5 | MD_EZI));

Chip_SSP_Init(LPC_SSP);

ssp_format.frameFormat = SSP_FRAMEFORMAT_SPI;
ssp_format.bits = SSP_BITS_16;//16;//SSP_DATA_BITS;
ssp_format.clockMode = SSP_CLOCK_MODE0;
Chip_SSP_SetFormat(LPC_SSP, ssp_format.bits, ssp_format.frameFormat, ssp_format.clockMode);
Chip_SSP_SetMaster(LPC_SSP, 0); // Set as Slave
Chip_SSP_Enable(LPC_SSP);

Polling:
        while (Chip_SSP_GetStatus(LPC_SSP, SSP_STAT_RNE)) {
                Chip_SSP_ReceiveFrame(LPC_SSP);
        }
        spi_data = *(unsigned short*)(temp_spi_data.rx_data);


Does anybody have an idea?  :~
Labels (1)
0 Kudos
Reply
10 Replies

1,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dark Star on Mon Aug 18 08:00:22 MST 2014
Right, I forgot to adapt the comments...
0 Kudos
Reply

1,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Fri Aug 15 02:51:08 MST 2014
Ah, I was mislead by the comments.
0 Kudos
Reply

1,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dark Star on Fri Aug 15 01:58:25 MST 2014
For MISO/MOSI Pin 1_3 and 1_4 is using. On page 233 of the chips user manual (UM10503, Rev 1.8) the SSP1 functions are in row 6 each, so function 5 has to be used. This should be correct...
0 Kudos
Reply

1,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Fri Aug 15 00:39:11 MST 2014
Function 5 for MISO/MOSI looks incorrect to me.

Jürgen
0 Kudos
Reply

1,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dark Star on Thu Aug 14 10:35:40 MST 2014
I see the clock, the data and the slave select. Master and slave, both are set to Mode 0 (first edge, positive clock). All the signals are looking correct (by oscilloscope) and are in the right phasing.
0 Kudos
Reply

1,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rocketdawg on Thu Aug 14 07:10:52 MST 2014
If you actually see the clock and the data on the pins, then it could be the mode.
It defines where the slave will sample the data in reference to the clock.
there are 4 different modes.
The masters mode might be defined, then set the slave mode appropriately.
0 Kudos
Reply

1,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dark Star on Thu Aug 14 05:46:22 MST 2014
Thanks for the tip, but I already had the newer library. So I configured SPI Pins like this:

/* SSP initialization */
Board_SSP_Init(LPC_SSP);

/* Set up clock and muxing for SSP1 interface */
/* PF.4 connected to SCL/SCLKSCU_MODE_FUNC1=SSP1 SCK1 */
Chip_SCU_PinMuxSet(0xF, 4, (SCU_PINIO_FAST | SCU_MODE_FUNC0));
/* P1.20 connected to nCSSCU_MODE_FUNC1=SSP1 SSEL1 */
Chip_SCU_PinMuxSet(0x1, 20, (SCU_PINIO_FAST | SCU_MODE_FUNC1));
/* P1.3 connected to SOSCU_MODE_FUNC1=SSP1 MISO1 */
Chip_SCU_PinMuxSet(0x1, 3, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC5));
/* P1.4 connected to nSISCU_MODE_FUNC2=SSP1 MOSI1 */
Chip_SCU_PinMuxSet(0x1, 4, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC5));

Chip_SSP_Init(LPC_SSP);

ssp_format.frameFormat = SSP_FRAMEFORMAT_SPI;
ssp_format.bits = SSP_BITS_16;//16;//SSP_DATA_BITS;
ssp_format.clockMode = SSP_CLOCK_MODE0;
Chip_SSP_SetFormat(LPC_SSP, ssp_format.bits, ssp_format.frameFormat, ssp_format.clockMode);
Chip_SSP_SetMaster(LPC_SSP, 0); // Set as Slave
Chip_SSP_Enable(LPC_SSP);

And this is to poll the permanently incoming data form the master:

while (Chip_SSP_GetStatus(LPC_SSP, SSP_STAT_RNE)) {
Chip_SSP_RWFrames_Blocking(LPC_SSP, &temp_spi_data);
}
spi_data = *(unsigned short*)(temp_spi_data.rx_data);

I still have the problem of an empty data register. I really do not find the reason of it...  :(
0 Kudos
Reply

1,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by whitecoe on Wed Aug 13 09:34:09 MST 2014
Don't know if this is relevant to you…

http://www.lpcware.com/content/forum/possible-error-pin-assignment-lpc4370

HTH!
0 Kudos
Reply

1,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dark Star on Wed Aug 13 02:30:05 MST 2014
The clock comes from the master. I configured it as a slave. The data I want to receive come from an other Controller which is the master. These data (MOSI, SCLK, SEL) are o.k. Also writing dummy data into the slave's data register doesn't make a difference. There are no received data in the data register...
0 Kudos
Reply

1,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rocketdawg on Tue Aug 12 07:35:09 MST 2014
SPI is a serial shift register protocol.
to read a byte, you must send a dummy byte.
the dummy is sent and at the same time, bit, by bit, the read value is received.
The clock only runs when there is something to send.
that is where the terms master/slave come into play.
0 Kudos
Reply