Hi Patroklos Anagonostou,
Sorry for my later reply!
I have test the lpcopen spi master in my LPCXpresso 54102 board, the GPIO PIO0_19 can track the SPI wave correctly.
This is my logic analyzer SPI wave

Clock rate is 4Mhz.

My modified code is lpc5410x_xpresso54102_keil_iar_v3.03.000_16, project periph_spi_sm_int.
Main code is :
int main(void)
{
int loop = 1;
uint16_t seed = 0;
volatile uint8_t *mstate, *sstate;
SystemCoreClockUpdate();
Board_Init();
Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 19);
Chip_GPIO_SetPinState(LPC_GPIO, 0, 19, true);
Chip_GPIO_SetPinOutHigh(LPC_GPIO, 0, 19);
Init_SPI_PinMux();
StopWatch_Init();
setupMaster();
setupSlave();
NVIC_EnableIRQ(LPC_SPIMASTERIRQNUM);
NVIC_EnableIRQ(LPC_SPISLAVEIRQNUM);
DEBUGOUT("SPI master/slave combined example\r\n");
while (loop) {
seed = bufferInit(seed);
masterTXBuffer16[0] = 0X1111;
masterTXBuffer16[1] = 0X2222;
spiMasterXfer.cbFunc = master_cb;
spiMasterXfer.state = SPIS_XFER_STATE_IDLE;
spiMasterXfer.txBuff = masterTXBuffer16;
spiMasterXfer.txCount = 1;
spiMasterXfer.rxBuff = masterRXBuffer16;
spiMasterXfer.rxCount = 1;
mstate = &spiMasterXfer.state;
spiMasterXfer.options =
SPIM_XFER_OPTION_SIZE(16) |
SPIM_XFER_OPTION_EOT |
SPIM_XFER_OPTION_EOF |
0;
spiMasterXfer.sselNum = 0;
masterTime = StopWatch_Start();
Chip_SPI_FlushFifos(LPC_SPIMASTERPORT);
Chip_GPIO_SetPinOutHigh(LPC_GPIO, 0, 19);
Chip_SPIM_Xfer(LPC_SPIMASTERPORT, &spiMasterXfer);
while ((*mstate != SPIM_XFER_STATE_DONE) ) {
}
Chip_GPIO_SetPinOutLow(LPC_GPIO, 0, 19);
spiMasterXfer.cbFunc = master_cb;
spiMasterXfer.state = SPIS_XFER_STATE_IDLE;
spiMasterXfer.txBuff = masterTXBuffer16+1;
spiMasterXfer.txCount = 1;
spiMasterXfer.rxBuff = masterRXBuffer16;
spiMasterXfer.rxCount = 1;
mstate = &spiMasterXfer.state;
spiMasterXfer.options =
SPIM_XFER_OPTION_SIZE(16) |
SPIM_XFER_OPTION_EOT |
SPIM_XFER_OPTION_EOF |
0;
spiMasterXfer.sselNum = 0;
masterTime = StopWatch_Start();
Chip_SPI_FlushFifos(LPC_SPIMASTERPORT);
Chip_GPIO_SetPinOutHigh(LPC_GPIO, 0, 19);
Chip_SPIM_Xfer(LPC_SPIMASTERPORT, &spiMasterXfer);
while ((*mstate != SPIM_XFER_STATE_DONE) ) {
}
Chip_GPIO_SetPinOutLow(LPC_GPIO, 0, 19);
Board_LED_Toggle(0);
while (Board_UARTGetChar() == EOF) {}
}
return 0;
}
I also attached my spi_sm_int.c file for your reference.
You can try my code on your side.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------