Hi.I have an SPI issue, may I know how to handle it? The official routine spi_transfer_rma_stlave calls the EXAMPLE_MasterStartDMATransfer() function twice in a row in the main function. The captured SPI waveform shows that the second transfer will raise the CS for each data. We need to send data for the second time, and only raise CS after the data is sent. It's not like raising CS every time we send data
void EXAMPLE_MasterStartDMATransfer(void)
{
uint32_t i = 0U;
dma_transfer_config_t masterTxDmaConfig, masterRxDmaConfig;
/* Prepare buffer to send and receive data. */
for (i = 0U; i < BUFFER_SIZE; i++)
{
txBuffer[i] = i;
rxBuffer[i] = 0U;
}
/* Prepare and start DMA RX transfer. */
DMA_PrepareTransfer(&masterRxDmaConfig, (void *)&EXAMPLE_SPI_MASTER->RXDAT, rxBuffer, sizeof(uint8_t), BUFFER_SIZE,
kDMA_PeripheralToMemory, NULL);
DMA_SubmitTransfer(&masterRxHandle, &masterRxDmaConfig);
/* Start DMA TX transfer. */
DMA_StartTransfer(&masterRxHandle);
/* Set the last byte to be sent, This will de-assert the SSEL pin when transmission is completed.
* If users want to assert the SSEL pin when transmission is completed, there is no need to set up this descriptor.
*/
lastData = txBuffer[BUFFER_SIZE - 1] | kSPI_EndOfTransfer | (EXAMPLE_SPI_MASTER->TXCTL & 0xFFFF0000);
/* DMA transfer configuration setting. */
dma_xfercfg_t tmp_xfercfg = {0};
tmp_xfercfg.valid = true;
tmp_xfercfg.swtrig = true;
tmp_xfercfg.intA = true;
tmp_xfercfg.byteWidth = sizeof(uint32_t);
tmp_xfercfg.srcInc = 0;
tmp_xfercfg.dstInc = 0;
tmp_xfercfg.transferCount = 1;
/* Create chained descriptor to transmit last word */
DMA_CreateDescriptor(&txDescriptor, &tmp_xfercfg, &lastData, (void *)&EXAMPLE_SPI_MASTER->TXDATCTL, NULL);
/* Add confifuration parameter to descriptor. */
DMA_PrepareTransfer(&masterTxDmaConfig, txBuffer, (void *)&EXAMPLE_SPI_MASTER->TXDAT, sizeof(uint8_t),
BUFFER_SIZE - 1, kDMA_MemoryToPeripheral, &txDescriptor);
/* Disable interrupts for first descriptor to avoid calling callback twice. */
masterTxDmaConfig.xfercfg.intA = false;
masterTxDmaConfig.xfercfg.intB = false;
DMA_SubmitTransfer(&masterTxHandle, &masterTxDmaConfig);
/* Start DMA TX transfer. */
DMA_StartTransfer(&masterTxHandle);
}
How can I modify this function? Or add other configurations? Thank you.
Hi,
Can you send us the project so that we can know the code context?
BR
Xiangjun Rong