AnsweredAssumed Answered

DAC Software trigger

Question asked by karpavicius.linas on May 3, 2014
Latest reply on May 5, 2014 by naughty_mark
Hello, somehow i can't find way to do software trigger to start DMA transfer of memory array to dac.
Original idea is to fill data array with my wavefrom, and use software trigger to start DMA transfer. Original sample of dac code use timer to do that, but i want to make it software. Since i was unable to find any fuction call that could do that, i switched to event triger, connected that line to EXTI line 9, and use software interrupt to generate event ( or interrupt, have no idea, since only interupt is possible), same effect, no output, not even single shot ( even if dma buffer is circual)

can some one tell me how can i initiate DMA transfer ? (also, if i have second dma transfer on different channel/stream, i can do that at the same time ? , since i use SPI to copy data to computer via FT232H in SPI mode, and i need at the same time to copy data from memory to 2 DACs separately  )

code for DAC init looks like this :

static void DAC_Ch1(void)
{
  DMA_InitTypeDef DMA_InitStructure;
 
  /* DAC channel1 Configuration */
  DAC_InitStructure.DAC_Trigger = DAC_Trigger_Software;
  DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
  DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
  DAC_Init(DAC_Channel_1, &DAC_InitStructure);
 
  DMA_DeInit(DMA1_Stream5);
  DMA_InitStructure.DMA_Channel = DMA_Channel_7; 
  DMA_InitStructure.DMA_PeripheralBaseAddr = DAC_DHR8R1_ADDRESS;
  DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&aEscalator8bit;
  DMA_InitStructure.DMA_BufferSize = 6;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;        
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
  DMA_Init(DMA1_Stream5, &DMA_InitStructure);   
 
  /* Enable DMA1_Stream5 */
  DMA_Cmd(DMA1_Stream5, ENABLE);
   
  /* Enable DAC Channel1 */
  DAC_Cmd(DAC_Channel_1, ENABLE);
 
  /* Enable DMA for DAC Channel1 */
  DAC_DMACmd(DAC_Channel_1, ENABLE);
}

Outcomes