The uTasker code you have presented uses totally different functions than the code I pasted. If we want to compare the code lets compare it to the SDK example frdmk64f_dspi_interrupt_b2b_master, which I am able to run without the issue I am having. Below I post its IRQHandler which I modified in order to reduce the four byte Fifo to one byte. I believe that I have converted it correctly. It would be too much detail to include the code which performs my byteRead() function, but I am using the identical functions as those used in the SDK example.
I am suspecting that the issue may be a result of incorrect configuration code, so I now list the related functions of both the SDK example code and mine, in order. There is one difference between them, as I point out below. Can someone tell me the significance of this difference?
frdmk64f_dspi_interrupt_b2b_master
srcClock_Hz = EXAMPLE_DSPI_MASTER_CLK_FREQ;
1 DSPI_MasterInit(EXAMPLE_DSPI_MASTER_BASEADDR, &masterConfig, srcClock_Hz);
2 EnableIRQ(EXAMPLE_DSPI_MASTER_IRQ);
3 masterCommand = DSPI_MasterGetFormattedCommand(&commandData);
4 masterFifoSize = FSL_FEATURE_DSPI_FIFO_SIZEn(EXAMPLE_DSPI_MASTER_BASEADDR);
5 DSPI_StopTransfer(EXAMPLE_DSPI_MASTER_BASEADDR);
6 DSPI_FlushFifo(EXAMPLE_DSPI_MASTER_BASEADDR, true, true);
7 DSPI_ClearStatusFlags(EXAMPLE_DSPI_MASTER_BASEADDR, (uint32_t)kDSPI_AllStatusFlag);
/*Fill up the master Tx data*/
8 while (DSPI_GetStatusFlags(EXAMPLE_DSPI_MASTER_BASEADDR) & kDSPI_TxFifoFillRequestFlag) …
My Code
1 DSPI_MasterInit(SPI2_PERIPHERAL, &SPI2_config, SPI2_CLK_FREQ)
This is the one function that is different. It was included by Config Tools:
I attempted to remove the second parameter to no avail.
DSPI_EnableInterrupts(SPI2_PERIPHERAL, (kDSPI_TxCompleteInterruptEnable |
kDSPI_EndOfQueueInterruptEnable));
2 EnableIRQ(SPI2_IRQN);
3 masterCommand = DSPI_MasterGetFormattedCommand(&commandData);
4 masterFifoSize = FSL_FEATURE_DSPI_FIFO_SIZEn(SPI2);
5 DSPI_StopTransfer(SPI2);
6 DSPI_FlushFifo(SPI2, true, true);
7 DSPI_ClearStatusFlags(SPI2, (uint32_t)kDSPI_AllStatusFlag);
8 while (DSPI_GetStatusFlags(SPI2) & kDSPI_TxFifoFillRequestFlag) …
Here is the IRQHandler straight out of the SDK example frdmk64f_dspi_interrupt_b2b_master. I already posted my version.
void EXAMPLE_DSPI_MASTER_IRQHandler(void) {
uint32_t tmpmasterTxCount = masterTxCount;
uint32_t tmpmasterRxCount = masterRxCount;
uint32_t tmpmasterCommand = masterCommand;
if (tmpmasterRxCount < TRANSFER_SIZE) {
while (DSPI_GetStatusFlags(EXAMPLE_DSPI_MASTER_BASEADDR) & kDSPI_RxFifoDrainRequestFlag) {
masterRxData[tmpmasterRxCount] = SPI_ReadData(EXAMPLE_DSPI_MASTER_BASEADDR);
++masterRxCount;
tmpmasterRxCount = masterRxCount;
DSPI_ClearStatusFlags(EXAMPLE_DSPI_MASTER_BASEADDR, kDSPI_RxFifoDrainRequestFlag);
if (tmpmasterRxCount == TRANSFER_SIZE) {
break;
}
}
}
if (tmpmasterTxCount < TRANSFER_SIZE) {
while ((DSPI_GetStatusFlags(EXAMPLE_DSPI_MASTER_BASEADDR) & kDSPI_TxFifoFillRequestFlag) && ((tmpmasterTxCount - tmpmasterRxCount) < masterFifoSize)) {
if (tmpmasterTxCount < TRANSFER_SIZE) {
EXAMPLE_DSPI_MASTER_BASEADDR->PUSHR = tmpmasterCommand | masterTxData[tmpmasterTxCount];
++masterTxCount;
tmpmasterTxCount = masterTxCount;
}
else
{
break;
}
/* Try to clear the TFFF; if the TX FIFO is full this will clear */
DSPI_ClearStatusFlags(EXAMPLE_DSPI_MASTER_BASEADDR, kDSPI_TxFifoFillRequestFlag);
}
}
/* Check if we're done with this transfer.*/
if ((tmpmasterTxCount == TRANSFER_SIZE) && (tmpmasterRxCount == TRANSFER_SIZE)) {
isTransferCompleted = true;
/* Complete the transfer and disable the interrupts */
DSPI_DisableInterrupts(EXAMPLE_DSPI_MASTER_BASEADDR,
kDSPI_RxFifoDrainRequestInterruptEnable | kDSPI_TxFifoFillRequestInterruptEnable);
}
SDK_ISR_EXIT_BARRIER;
}