Hello,
I am trying to get the SSP running with DMA on the LPC4357.
For this I configured 1 DMA channel for TX and 1 DMA channel for RX.
However the RX buffer always stays empty.
I have configured the DMA as following:
NVIC_DisableIRQ(DMA_IRQn);
NVIC_SetPriority(DMA_IRQn, ((0x01 << 3) | 0x01));
GPDMA_Init();
GPDMA_Channel_CFG_Type dma_txconfig;
dma_txconfig.ChannelNum = 0;
dma_txconfig.TransferSize = n;
dma_txconfig.TransferWidth = GPDMA_WIDTH_BYTE;
dma_txconfig.SrcMemAddr = (uint32_t)&txbuf;
dma_txconfig.DstMemAddr = 0;
dma_txconfig.TransferType = GPDMA_TRANSFERTYPE_M2P_CONTROLLER_DMA;
dma_txconfig.SrcConn = 0;
dma_txconfig.DstConn = GPDMA_CONN_SSP1_Tx;
dma_txconfig.DMALLI = 0;
GPDMA_Setup(&dma_txconfig);
GPDMA_Channel_CFG_Type dma_rxconfig;
dma_rxconfig.ChannelNum = 1;
dma_rxconfig.TransferSize = n;
dma_rxconfig.TransferWidth = GPDMA_WIDTH_BYTE;
dma_rxconfig.SrcMemAddr = 0;
dma_rxconfig.DstMemAddr = (uint32_t)&rxbuf;
dma_rxconfig.TransferType = GPDMA_TRANSFERTYPE_P2M_CONTROLLER_DMA;
dma_rxconfig.SrcConn = GPDMA_CONN_SSP1_Rx;
dma_rxconfig.DstConn = 0;
dma_rxconfig.DMALLI = 0;
GPDMA_Setup(&dma_rxconfig);
Channel0_TC = 0;
Channel0_Err = 0;
Channel1_TC = 0;
Channel1_Err = 0;
NVIC_EnableIRQ(DMA_IRQn);
GPDMA_ChannelCmd(0, ENABLE);
SSP_DMACmd(spip->ssp, SSP_DMA_TX, ENABLE);
GPDMA_ChannelCmd(1, ENABLE);
SSP_DMACmd(spip->ssp, SSP_DMA_RX, ENABLE);
while (((Channel0_TC == 0) && (Channel0_Err == 0)) || ((Channel1_TC == 0) && (Channel1_Err == 0)));
My SPI is configured for 8bit, so I setup the DMA Transferwidth to the same.
This is inside my SPI send function, so 'n' will be the amount of bytes to be transferred.
The Channel0_TC and Channel1_TC are set correctly to 1 in the DMA interrupt.
But the rxbuf configured for the RX DMA stays empty...
Anyone a pointer what might go wrong here?
Cheers,
Gerard
dma_txconfig.SrcConn = 0;
I just found out I made a stupid mistake.
It was solved by removing the & in front of my buffers.
The following changes results in a working DMA on ssp:
dma_txconfig.SrcMemAddr = (uint32_t)txbuf;
dma_rxconfig.DstMemAddr = (uint32_t)rxbuf;