2023-01-11 05:47 PM
Hello all
I would like to do SPI through DMA.
Before transmitting data, we want to send the command of the PUSHR register together, so one channel wants to combine the data and transmit it through the minor loop link.
However, there is a problem that it is not transmitted correctly. (data_array2 has been confirmed to be changed correctly.)
Below is my code.
vuint32_t data_array2[32] = {0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x80010000, 0x08010000};
uint16_t data_array3[32] = {0xFFA1, 0xFFA2, 0xFFA3, 0xFFA4, 0xFFA5, 0xFFA6, 0xFFA7, 0xFFA8, 0xFFB1, 0xFFB2, 0xFFB3, 0xFFB4, 0xFFB5, 0xFFB6, 0xFFB7, 0xFFB8, 0xFFC1, 0xFFC2, 0xFFC3, 0xFFC4, 0xFFC5, 0xFFC6, 0xFFC7, 0xFFC8, 0xFFD1, 0xFFD2, 0xFFD3, 0xFFD4, 0xFFD5, 0xFFD6, 0xFFD7, 0xFFD8};
void EDMA_test(void)
{
EDMA_1.CH[13].TCD_SADDR.R = (uint32_t)&data_array3;
EDMA_1.CH[13].TCD_ATTR.B.SMOD = 0;
EDMA_1.CH[13].TCD_ATTR.B.SSIZE = 1;
EDMA_1.CH[13].TCD_ATTR.B.DMOD = 0;
EDMA_1.CH[13].TCD_ATTR.B.DSIZE = 1;
EDMA_1.CH[13].TCD_SOFF.B.SOFF = 2;//
EDMA_1.CH[13].TCD_NBYTES.B_MLOFFNO.NBYTES = 2;
EDMA_1.CH[13].TCD_SLAST.R = 0;
EDMA_1.CH[13].TCD_DADDR.R = ((uint32_t)&data_array2) + 2;
EDMA_1.CH[13].TCD_CITER.B_ELINKYES.ELINK = 1;
EDMA_1.CH[13].TCD_CITER.B_ELINKYES.LINKCH = 1;
EDMA_1.CH[13].TCD_CITER.B_ELINKYES.CITER = 32;
EDMA_1.CH[13].TCD_BITER.B_ELINKYES.ELINK = 1;
EDMA_1.CH[13].TCD_BITER.B_ELINKYES.LINKCH = 1;
EDMA_1.CH[13].TCD_BITER.B_ELINKYES.BITER = 32;
EDMA_1.CH[13].TCD_DOFF.R = 4;
EDMA_1.CH[13].TCD_DLASTSGA.R = 0;
EDMA_1.CH[13].TCD_CSR.B.BWC = 0;
EDMA_1.CH[13].TCD_CSR.B.MAJORLINKCH = 0; /* Linking */
EDMA_1.CH[13].TCD_CSR.B.MAJORELINK = 0;
EDMA_1.CH[13].TCD_CSR.B.ESG = 0;
EDMA_1.CH[13].TCD_CSR.B.DREQ = 1;
EDMA_1.CH[13].TCD_CSR.B.INTHALF = 0;
EDMA_1.CH[13].TCD_CSR.B.INTMAJOR = 0;
EDMA_1.CH[13].TCD_CSR.B.START = 1;
}
void EDMA_test_send(void)
{
EDMA_1.CH[1].TCD_SADDR.R = (uint32_t)&data_array2;
EDMA_1.CH[1].TCD_ATTR.B.SMOD = 0;
EDMA_1.CH[1].TCD_ATTR.B.SSIZE = 2;
EDMA_1.CH[1].TCD_ATTR.B.DMOD = 0;
EDMA_1.CH[1].TCD_ATTR.B.DSIZE = 2;
EDMA_1.CH[1].TCD_SOFF.B.SOFF = 4;//
EDMA_1.CH[1].TCD_NBYTES.B_MLOFFNO.NBYTES = 4;
EDMA_1.CH[1].TCD_SLAST.R = 0;
EDMA_1.CH[1].TCD_DADDR.R = (vuint32_t)&DSPI_3.PUSHR.R;
EDMA_1.CH[1].TCD_CITER.B_ELINKNO.ELINK = 0;
EDMA_1.CH[1].TCD_CITER.B_ELINKNO.CITER = 1;
EDMA_1.CH[1].TCD_BITER.B_ELINKNO.ELINK = 0;
EDMA_1.CH[1].TCD_BITER.B_ELINKNO.BITER = 1;
EDMA_1.CH[1].TCD_DOFF.R = 0;
EDMA_1.CH[1].TCD_DLASTSGA.R = 0;
EDMA_1.CH[1].TCD_CSR.B.BWC = 0;
EDMA_1.CH[1].TCD_CSR.B.MAJORLINKCH = 13; /* Linking */
EDMA_1.CH[1].TCD_CSR.B.MAJORELINK = 1;
EDMA_1.CH[1].TCD_CSR.B.ESG = 0;
EDMA_1.CH[1].TCD_CSR.B.DREQ = 1;
EDMA_1.CH[1].TCD_CSR.B.INTHALF = 0;
EDMA_1.CH[1].TCD_CSR.B.INTMAJOR = 0;
}