AnsweredAssumed Answered

SPI-DMA continuous package send problem

Question asked by Umit Kayacik on Jul 6, 2015
Latest reply on Jul 13, 2015 by Lukas Zadrapa

There is a problem with my SPI-DMA continuous package send algorithm. First, I set SPI DMA configuration with DPSI_RSER register like below,

 

    DSPI_B.RSER.R = 0x03030000;

            /* Transmission Complete Request : Disable    */

            /* DSPI Finished Request : Disable    */

            /* Transmit FIFO Underflow Request Enable : Disable    */

            /* Transmit FIFO Fill Request Enable : Enable    */

            /* Transmit FIFO Fill DMA or Interrupt Request : DMA    */

            /* SPI Parity Error Interrupt Request :Disable    */

            /* Receive FIFO Overflow Request Enable : Disable    */

            /* Receive FIFO Drain Request Enable : Enable    */

            /* Receive FIFO Drain DMA Interrupt Request : DMA    */

 

    EDMA.TCD[12].SOFF =  (vint16_t)0x0004;/* Source Address Signed Offset  */

    EDMA.TCD[12].NBYTES = 0x00000004;/* Inner 'minor' byte count   */

    EDMA.TCD[12].SLAST = (vint32_t) 0xfffffbf0;/* Last Source Address Adjustment 260 byte*/

    EDMA.TCD[12].BITER  = 0x0104;/* Beginning major iteration count or link channel number */

    EDMA.TCD[12].CITER  = 0x0104;/* Current major iteration count or link channel number */

 

I control to start major loop with : EDMA.ERQRL.R   = 0x00001000; /* Ch 12 DMA for SPI- Tx */ 

 

 

I use this configuration to talk with M32P Flash controller. I have just tried to page program with polling it works perfect but when I tried to send 256 Byte package with DMA following problem occur:

 

1) First package is perfect but other packages are not correct. For second and the other packaged before WREN there are 4 ghost bytes occur. This 4 bytes are going like first "PP+3Byte address" bytes later "4 pre data " later "8 to 12 data".

 

/* Just for WREN */

DSPI_B.SR.R = DSPI_SR_EOQF;

DSPI_B.PUSHR.R = NOR_end_command_for_PUSH(WREN);

while (!(DSPI_B.SR.B.RFDF)) {}

n = (uint8_t) (DSPI_B.POPR.R);

DSPI_B.SR.R = DSPI_SR_RFDF

 

/* DMA data send */

DSPI_B.SR.R = DSPI_SR_EOQF;

EDMA.ERQRL.R   = 0x00001000; /* Ch 12 DMA for SPI- Tx */ 

 

Then it should send package.

 

Not: To page program flash needs WREN Byte must send to flash. My routine is like:  send WREN(with EOQ) + PP + 3 Byte Address + 256Byte data (last one with EOQ-End Of Queue that set Chip Select to Low) and change data and send routine again

 

Could you please help me to send this whole package in one DMA MAJOR loop or with my above solution?

Outcomes