SPI-DMA continuous package send problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI-DMA continuous package send problem

Jump to solution
1,910 Views
u_kayacik
Contributor II

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?

Labels (1)
Tags (4)
0 Kudos
1 Solution
1,058 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

attached you will find SW example how to send packet of bytes via SPI.

Two DMA channels are used. First channel is triggered by DSPI and it transfers one byte of data to 32bit word (command) that will be written to PUSHR register. Once the transfer is done, link is used for next channel that transfers the command to PUSHR register.

We have to always write 32bit PUSHR register at once - both data and other control bits must be written at the same time. So, one solution is to have prepared 32bit words in RAM that will be written to PUSHR register directly by one DMA channel. Second solution is used in this example - we have 8bit data prepared in RAM and then two DMA channels are used to prepare 32bit command word.

Best Regards,

Lukas

View solution in original post

0 Kudos
2 Replies
1,059 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

attached you will find SW example how to send packet of bytes via SPI.

Two DMA channels are used. First channel is triggered by DSPI and it transfers one byte of data to 32bit word (command) that will be written to PUSHR register. Once the transfer is done, link is used for next channel that transfers the command to PUSHR register.

We have to always write 32bit PUSHR register at once - both data and other control bits must be written at the same time. So, one solution is to have prepared 32bit words in RAM that will be written to PUSHR register directly by one DMA channel. Second solution is used in this example - we have 8bit data prepared in RAM and then two DMA channels are used to prepare 32bit command word.

Best Regards,

Lukas

0 Kudos
1,058 Views
u_kayacik
Contributor II

Could you please help me to trigger DMA with SPI's status register manually?

Ümit

0 Kudos