AnsweredAssumed Answered

SPI xfer using DMA: How to transmit again?

Question asked by mendes.ari.001 on Aug 17, 2012
Latest reply on Nov 13, 2014 by karpavicius.linas
 The code below transmits 8 bytes from a sram buffer to SP1 using DMA.

 for(i=0;i<8;i++) SPI_MASTER_Buffer_Tx[i] = i+1;
  
  /* SPI_MASTER configuration ------------------------------------------------*/
  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
  SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8;
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
  SPI_InitStructure.SPI_CRCPolynomial = CRCPolynomial;
  SPI_Init(SPI1, &SPI_InitStructure);
  SPI_Cmd(SPI1, ENABLE);
  /* SPI_MASTER_Rx_DMA_Channel configuration ---------------------------------*/
  DMA_DeInit(DMA1_Channel3);  
  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)SPI_MASTER_DR_Base;
  DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)SPI_MASTER_Buffer_Tx;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
  DMA_InitStructure.DMA_BufferSize = 8;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
  DMA_InitStructure.DMA_Priority = DMA_Priority_Low;
  DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
  DMA_Init(DMA1_Channel3, &DMA_InitStructure);
   /* Enable DMA channels */
  DMA_Cmd(DMA1_Channel3, ENABLE);
  /* Enable SPI_MASTER DMA Tx request */
  SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Tx, ENABLE);
  /* Transfer complete */
  while(!DMA_GetFlagStatus(DMA1_FLAG_TC3));
   
  How to transmit the buffer again? I tried it with the code below with no success.
  
      DMA_ClearFlag(DMA1_FLAG_TC3);
      DMA_Cmd(DMA1_Channel3, ENABLE);
      SPI_I2S_DMACmd(SPI_MASTER, SPI_I2S_DMAReq_Tx, ENABLE);
      while(!DMA_GetFlagStatus(DMA1_FLAG_TC3));


Outcomes