I imported the frdmkl46z_spi_interrupt_b2b_transfer_master project in the SDK into MCUXpresso IDE. In addition, I did not connect anything to any pins on FRDM-KL46Z. Following is part of the code in the main function.
for (i = 0; i < BUFFER_SIZE; i++)
{
srcBuff[i] = i;
}
/* Send to slave */
xfer.txData = srcBuff;
xfer.rxData = destBuff;
xfer.dataSize = BUFFER_SIZE;
SPI_MasterTransferCreateHandle(EXAMPLE_SPI_MASTER, &handle, masterCallback, NULL);
SPI_MasterTransferNonBlocking(EXAMPLE_SPI_MASTER, &handle, &xfer);
while (masterFinished != true)
{
}
/* Check if the data is right */
for (i = 0; i < BUFFER_SIZE; i++)
{
if (srcBuff[i] != destBuff[i])
{
err++;
PRINTF("The %d is wrong! data is %d\n\r", i, destBuff[i]);
}
}
if (err == 0)
{
PRINTF("Succeed!\n\r");
}
As you may figure out, the txData is 0-(BUFFER_SIZE - 1). Meanwhile, the program itself is expecting the rxData would be same as the txData. Indeed, after running the program, the values in destBuff is same as those in srcBuff, which will not happen if I did not connect anything to the board. You may have a try since it is pretty straightforward. I suspect that some settings in the project connect the MOSI and MISO bus internally, but I did not find such setting.
Thank you for the help!