I am working with the LPC55S69 eval kit where it has Flexcomm7 SPI set up as a slave. Using the SDK's example called "spi interrupt" (boards->lpcxpresso55s69->driver_examples->spi->interrupt) I am able to run the demo where FC7 is master and FC2 is slave, where the appropriate wires are crossed on the dev kit.
For my board, I need FC7 to be the slave.
I can get my project working ONLY IF the SDK's example was previously loaded onto the board, power is maintained, and then my project is loaded. The test method is an external Raspberry Pi as SPI master and sending SPI commands to my project using its GPIO pin header.
If I power down the board and disconnect everything, then power back up and load ONLY my project, the SPI doesn't work. The Master sends ASCII commands as "VTC 45". My logic analyzer, configured as SPI, shows the ASCII commands 0x56 0x54 0x43 0x20 0x34 0x35 0x0A on MOSI, which corresponds to the ASCII characters. With a debugger set to break on the FC7 IRQ Handler, the value of SPI_ReadData() shows 0x01, 0x01, 0x01, 0x02, 0x01, 0x01.
Without disconnecting any hardware and leaving the power on, I go and load the SDK example. I don't even need to run it. Keeping power on still, I switch over to my project and load it. Now SPI works correctly. The IRQ handler shows 0x56 0x54 0x43 0x20 ... etc and it works correctly.
I have modified the SDK to print the Flexcomm values just before the example transfers occurs, and it looks like this:
SDK Flexcomm2 Slave Values
--- SYSCON Clock Control ---
AHBCLKCTRL0: 0x E1FB
AHBCLKCTRL1: 0x 42800
AHBCLKCTRL2: 0x 9842000
FCCLKSEL7: 0x 2 (FRO12M)
FLEXFRG2CTRL: 0x FF
CLOCKLOCK: 0x 0 [unlocked]
--- SYSCON Reset Control ---
PRESETCTRL0: 0x 0
PRESETCTRL1: 0x 0
PRESETCTRL2: 0x 0
--- FLEXCOMM ---
PSELID: 0x 1020F2 (SPI mode)
--- SPI Configuration ---
CFG: 0x 1 [EN=1 MASTER=0 CPOL=0 CPHA=0]
DLY: 0x 0
STAT: 0x 100
INTENSET: 0x 0
DIV: 0x 0
--- SPI FIFO ---
FIFOCFG: 0x 13 [ENTX=1 ENRX=1]
FIFOSTAT: 0x 30
FIFOTRIG: 0x 3
FIFOINTENSET: 0x 0
--- Pin Configuration (IOCON) ---
PIO0_19 (MISO): 0x 121 [FUNC=1 MODE=0]
PIO0_20 (MOSI): 0x 121 [FUNC=1 MODE=0]
PIO0_21 (SCK): 0x 121 [FUNC=1 MODE=0]
PIO1_20 (SSEL): 0x 121 [FUNC=1 MODE=0]
I then did the same in my project. I printed it both from a cold start (the SDK is not loaded, and SPI fails) and also a warm start (SDK is loaded, SPI succeeds) and its output looks like this:
Project Flexcomm7 Slave Values
--- SYSCON Clock Control ---
AHBCLKCTRL0: 0x E1FB
AHBCLKCTRL1: 0x 42800
AHBCLKCTRL2: 0x 9842000
FCCLKSEL: 0x 2 (FRO12M)
FLEXFRGCTRL: 0x FF
CLOCKLOCK: 0x 0 [unlocked]
--- SYSCON Reset Control ---
PRESETCTRL0: 0x 0
PRESETCTRL1: 0x 0
PRESETCTRL2: 0x 0
--- FLEXCOMM ---
PSELID: 0x 1020F2 (SPI mode)
--- SPI Configuration ---
CFG: 0x 1 [EN=1 MASTER=0 CPOL=0 CPHA=0]
DLY: 0x 0
STAT: 0x 100
INTENSET: 0x 0
DIV: 0x 0
--- SPI FIFO ---
FIFOCFG: 0x 13 [ENTX=1 ENRX=1]
FIFOSTAT: 0x 30
FIFOTRIG: 0x 3
FIFOINTENSET: 0x 8
--- Pin Configuration (IOCON) ---
PIO0_19 (MISO): 0x 127 [FUNC=7 MODE=0]
PIO0_20 (MOSI): 0x 127 [FUNC=7 MODE=0]
PIO0_21 (SCK): 0x 127 [FUNC=7 MODE=0]
PIO1_20 (SSEL): 0x 121 [FUNC=1 MODE=0]
The only difference I see is the FIFOINTSET, but even with the difference printed out it still works only AFTER I have loaded the SDK and switched over.
I have poured over the SDK's example of setting up the clocks, resetting peripherals, etc. and am unable to find anything different that my project is doing EXCEPT for the fact that the SDK uses Flexcomm7 as master, and I use it as slave.
What is most perplexing is that my project will NOT work unless the SDK has been loaded first. This indicates to me that there is some residual hardware setup that mine is not doing because it persists when the a different binary is loaded. But it doesn't work from a cold start.
Any help would be greatly appreciated!