2015-10-04 08:07 AM
Hi all,
I am not sure about a DMA config for DAC on STM32F2. Could you please tell me if I made an error using 8bits words with this DMA config? Especially with DAC base address?#define BUFFERSIZE 128
__IO uint8_t DAC_data_8bits_DAC_1[ BUFFERSIZE ];
__IO uint8_t DAC_data_8bits_DAC_2[ BUFFERSIZE ];
/// configure DMA : DAC1 -> DAC_SetChannel1Data()
DMA_InitTypeDef DMA_InitStructure;
/* DMA1_Stream5 channel7 configuration **************************************/
DMA_DeInit(DMA1_Stream5);
DMA_InitStructure.DMA_Channel = DMA_Channel_7;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)( DAC_BASE + DHR12R1_OFFSET + DAC_Align_8b_R); ///
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&DAC_data_8bits_DAC_1; //
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_InitStructure.DMA_BufferSize = BUFFERSIZE;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; /// DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; /// DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; /// DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
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;
/// configure DMA : DAC2 -> DAC_SetChannel2Data()
DMA_InitTypeDef DMA_InitStructure;
/* DMA1_Stream6 channel7 configuration **************************************/
DMA_DeInit(DMA1_Stream6);
DMA_InitStructure.DMA_Channel = DMA_Channel_7;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)( DAC_BASE + DHR12R2_OFFSET + DAC_Align_8b_R); /// DAC_DHR8R2_DACC2DHR address
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&DAC_data_8bits_DAC_2; //
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_InitStructure.DMA_BufferSize = BUFFERSIZE;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; /// DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; /// DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; /// DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
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);
DMA_Init(DMA1_Stream6, &DMA_InitStructure);
DMA_Cmd(DMA1_Stream5, ENABLE);
DMA_Cmd(DMA1_Stream6, ENABLE);
DAC_DMACmd(DAC_Channel_1, ENABLE);
DAC_DMACmd(DAC_Channel_2, ENABLE);
/* Enable DMA Stream Transfer Complete interrupt */
DMA_ITConfig( DMA1_Stream5_IRQn, DMA_IT_TC, ENABLE); /// ---> DMA1_Stream5_IRQHandler()
DMA_ITConfig( DMA1_Stream6_IRQn, DMA_IT_TC, ENABLE); /// ---> DMA1_Stream6_IRQHandler()
Thank you!
#dac-dma-stm32f2
2015-10-05 02:37 AM
Address seems to be ok...
My problem is that it works with one channel, but when trying with both DAC channels enabled with DMA, it only loads (and lock) on the first value.Anyone please ?Thank you!2015-10-08 03:55 AM
Hi rocca.stephane,
In your code, I don't see the DAC channels enabled (call of DAC_Cmd function).-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.