SPI Slave Receive on LPC 812

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by Rorrik on Tue Sep 23 14:53:36 MST 2014
I am attempting to use the LPC812 as a relay device for a SPI channel. The goal is to receive a signal and process it in order to send a derived signal on the to the target device. This means that one SPI channel on the LPC812 is functioning as a Master and the other as a Slave.

I seem to have the Master channel working properly. It transmits the correct messages when hard coded to do so and successfully programs the target device.

However, on the Slave or receive side, I can't seem to see the signal. I am always stuck in this while loop in the provided ReadFrames function: while (!(Chip_SPI_GetStatus(pSPI) & SPI_STAT_RXRDY)) {}, even though it is while ( !( 0xFF & 0x01 ) ), which should exit immediately.

I've removed the loop to get around this problem in the meantime, but somehow my entire signal is missed. I can see that the signal is on the MOSI pin using a O-scope, but in the code, I never see anything non-zero when the pin is set to be MOSI. If I punt and set it to MISO against all logic, I start seeing 0xFF over and over, but only after my signal has already passed.

I think MOSI is the right way to go, but I can't see a signal there. What am I missing? My Master clock is 100 kHz and I've set the receive clock to 2.4 MHz to be safe: ConfigStruct0.ClkDiv = Chip_SPI_CalClkRateDivider(LPC_SPI0, 2400000); Since I read I needed to be 12x as fast. Do I instead need to change the peripheral clock? How can I do that? Is there something else I should be looking at?


EDIT: So far I've just been modifying the example code attached.

Original Attachment has been moved to: spi.c.zip