Hello,
I am trying to use DMA with SPI on the new F28388D control board. I based my initialization on the several examples I've been available to find.
I use the SPIB and DMA channel 5 for Tx.
Here are my initializations:
static void HAL_comSPI_init(HAL* hal)
{
// Disable SPI before configuration
SPI_disableModule(hal->comSpiHandle);
// Initialize FIFO
SPI_enableFIFO(hal->comSpiHandle);
SPI_clearInterruptStatus(hal->comSpiHandle, SPI_INT_RXFF | SPI_INT_TXFF);
SPI_setFIFOInterruptLevel(hal->comSpiHandle, SPI_FIFO_TX8, SPI_FIFO_RX8);
// Set SPI configuration
SPI_setConfig(hal->comSpiHandle, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0, SPI_MODE_SLAVE, 400E3, 16);
// Free run
SPI_setEmulationMode(hal->comSpiHandle, SPI_EMULATION_FREE_RUN);
// Enable SPI module
SPI_enableModule(hal->comSpiHandle);
}
static void HAL_DMA_init(HAL* hal)
{
// DMA initialization
DMA_initController();
// DMA Tx channel initialization
DMA_configAddresses(hal->dmaTxHandle, (uint16_t*)(hal->comSpiHandle + SPI_O_TXBUF), dualSourceBuffer.comPackets);
// Single word per burst
DMA_configBurst(hal->dmaTxHandle, COM_LENGTH, 1, 0);
//DMA_configTransfer(hal->dmaTxHandle, COM_LENGTH, -(COM_LENGTH - 1), 0); // TODO recheck
DMA_configTransfer(hal->dmaTxHandle, 1, -(COM_LENGTH - 1), 0);
// 16-bits words, no one-shot mode
DMA_configMode(hal->dmaTxHandle, DMA_TRIGGER_SPIBTX, DMA_CFG_ONESHOT_DISABLE |
DMA_CFG_CONTINUOUS_DISABLE | DMA_CFG_SIZE_16BIT);
DMA_clearTriggerFlag(hal->dmaTxHandle);
}
And later in the initialization, I call:
DMA_startChannel(hal->dmaTxHandle);
When I launch the code, this is what I see:
SPI registers:
DMA Mode register
DMA Control register
The FIFO buffer seems to somehow be filled because TXFFSTS is equal to 7 but I dont get why.
Also when I read this buffer from an external SPI master I only read zeros and the TXFFSTS is decrementing properly
Thanks in advance.
Natan


