Hi Mark,
Have you attempted or given some thought into using DMA for SPI? I'm *trying* to implement DMA in the SD write routine for my M52259 board, but I'm having no luck.
Specifically, I'm trying to replace the WRITE_SPI_CMD(BYTE) function. Here is what I have so far:
void utWriteSPICmdWithDMA(unsigned char *ptrBuf, signed long ulLength)
{
// Allow access to SPI for DMA
GPACR0 = SUP_USER_FULL_ACCESS;
PACR_QSPI = SUP_USER_FULL_ACCESS;
// DMA
// Config SPI registers
QAR = QSPI_TRANSMIT_RAM_0;
QWR = ((0 << QSPI_START_SHIFT) | (0 << QSPI_END_SHIFT));
// Setup DMA
DMA_SR_BCR2 = ulLength;
DMA_SAR2 = (unsigned long)ptrBuf; // address of first byte to be transferred (SARn)
DMA_DAR2 = (unsigned long)(QSPI_ADD + 0x14); // address of first destination byte (DARn) = QDR
DMA_DCR2 = (DCR_BWC_16K | DCR_SINC | /*DCR_DINC |*/ DCR_SSIZE_BYTE | DCR_DSIZE_BYTE | DCR_START); // set up DMA operation (DCRn) and start DMA transfer
while (!(DMA_SR_BCR2 & DSR_DONE)) { }; // wait until the transfer has terminated
QDLYR = QSPI_SPE;
// DMA transfer done.
DMA_SR_BCR2 = DSR_DONE; // clear all status bits ready for future transfer
}
After running this code I probed the clock, DataIn, and ChipSelect lines, all look OK. But no writes ever take place...the QSPI data register is always empty and the DMA status register reports no error either.
There are almost NO examples or anything online relating to using DMA with QSPI on my board (or any other boards for that matter!). Your DMA+UART code helps, but there are differences (I'm guessing) that prevent it from working. Shouldn't DMA automatically take care of handling the SPI though?
Does anyone have any ideas as well? Insights? Anything is appreciated!
Thanks!
Justin