This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SM470R1B1M-HT SPI RX using DMA

Other Parts Discussed in Thread: CC2640

Hello,

I am working for a project in which i need to communicate SM470 with FPGA over SPI protocol, using DMA.

My code for only transmitting the data to FPGA over SPI using DMA is running fine,

But the code for receiving data over SPI using DMA  from FPGA is not working, i have gone thru all that was given in datasheet, but helpless.

i know that SPI is a full duplex communication protocol in which the controller has to send some dummy data to SPI1DAT0 to receive data from FPGA. But i am confused how can i write the SPI1DAT0 when i have to receive data using DMA.

I have done thru the SPD, still i am unable to understand how i can initiate the SPI RX DMA.

Do i need to transmit data over any channel to receieve data in SPI1BUF through DMA, if yes then how?

As sending and receiving channels are different for DMA and both having different priority.

My code are:-

void Init_spi_rx_dma(uint32* Dest, uint32 count)
 {
  DMAC04 = INTEN | DSTINC | DSTMOD_2 | SRCMOD_15 | TRSIZE_1; // Interrupt enable, Dstination address increment, destination on fine memory select 2, source on Expansion bus peripherals, data size 16 bit
  DMASA04 = (unsigned long)&SPI1BUF;    // set the source address
  DMADA04 = (unsigned long)Dest;        // set the destination address
  DMATC04 = count;                      // set the DMA transfer count.  
  DMACC0 |= IL1 | SEN1 | RQEN1;         // DMA Channel 1(SPI1 RX) config: using interrupt line 1, 
  DMAGC  = 0x0;                         // DMA Global config
  DMAGD  = 0X0;                         // Clear DMA Globa Disable register
  DMAS   &= ~(IF1 | TC);                // Clear transfer complete flag and interrupt flag
  DMACPS  = 0x01;                       // Indicate control packet 0 is updated and will be used for transfer thru channel 1
  DMACCP0 = DMEN1 | CCPACK1_4;          // Enalbe DMA Channel 1 using control packet 0
 }


void Init_spi_tx_dma(uint32* source, uint32 count)
 {
    DMAC02 = INTEN | TRSIZE_1 | SRCINC | DSTMOD_15 | SRCMOD_2;// Interrupt enable, source address increment, source on fine memory select 2, destination on Expansion bus peripherals, data size 16 bit
    DMADA02 = (unsigned long)&SPI1DAT0;      // set the source address   
    DMATC02 = count;                         // set the destination address
    DMASA02 = (unsigned long)source;         // set the DMA transfer count
    DMACC0 = IL2 | SEN2 | RQEN2;             // DMA Channel 2(SPI1 TX) config: using interrupt line 1, 
    DMAGC  = 0x0;                            // DMA Global config        
    DMAGD  = 0X0;                            // Clear DMA Globa Disable register        
    DMAS   &= ~(IF2 | TC);                   // Clear transfer complete flag and interrupt flag
    DMACPS  |= 0x04;                         // Indicate control packet 2 is updated and will be used for transfer thru channel 2
    DMACCP0 = DMEN2 | CCPACK2_2;             // Enalbe DMA Channel 2 using control packet 2
 }

My SPI init routine is :-

void Init_SPI1(void)
{
  SPI1CTRL1 = 0 | CHARLEN_16; // 16 bits per xfer
  SPI1CTRL1 |= PRESCALE0 | PRESCALE1; // SPICLK = 64MHz/(3+1)=  16 MHz,   SPICLK=(ICLK)/(Prescale + 1)

  SPI1PC1 &= ~ENA_DIR;
  SPI1PC1 |= SCS_DIR;
  
  SPI1CTRL2 |= MASTER; // We are the master
  SPI1CTRL2 |= CLKMOD; //We drive the clock
 
  
  SPI1PC6 |= CLK_FUN;
  SPI1PC6 |= SIMO_FUN;
  SPI1PC6 |= SOMI_FUN;
  
  SPI1CTRL3 |= DMA_REQ_EN;

  SPI1CTRL2 |= SPIEN;
  // CS High
  SPI1PC3 |= SCS_DOUT;
}

Please help me with how to receive data over DMA using SPI1RX.

Regards,

Amjad