有了之前调试SDADC的经历,我对ST的官方例程是无比相信的,然后这次在调试DAC按照它的配置怎么也输出不了波形,然后没办法,翻Reference manual,看能否找出蛛丝马迹;
DAC的那节没看出毛病,该配置的也配置了;
然后锁定到DMA,官方例程用的是DMA2;
**DAC channel 1对应的 DMA2通道Channel3;
DAC channel 2对应的 DMA2通道Channel4;**
而官方例程上,正好反过来了,改过来波形就发出来了;
/* The sine wave and the escalator wave has been selected */
/* Sine Wave generator ---------------------------------------------*/
/* DAC channel2 Configuration */
DAC_DeInit(DAC1);
DAC_InitStructure.DAC_Trigger = DAC_Trigger_T2_TRGO;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
/* DAC Channel2 Init */
DAC_Init(DAC1, DAC_Channel_2, &DAC_InitStructure);
/* Enable DAC Channel2 */
DAC_Cmd(DAC1, DAC_Channel_2, ENABLE);
/* DMA2 channel3 configuration */
DMA_DeInit(DMA2_Channel3);
DMA_InitStructure.DMA_PeripheralBaseAddr = DAC_DHR12R2_ADDRESS;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&Sine12bit;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 32;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA2_Channel3, &DMA_InitStructure);
****/* Enable DMA2 Channel3 */
DMA_Cmd(DMA2_Channel3, ENABLE);
/* Enable DMA for DAC Channel2 */
DAC_DMACmd(DAC1, DAC_Channel_2, ENABLE);****
/* Escalator Wave generator ----------------------------------------*/
/* DAC channel1 Configuration */
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
DAC_Init(DAC1, DAC_Channel_1, &DAC_InitStructure);
/* DMA2 channel4 configuration */
DMA_DeInit(DMA2_Channel4);
DMA_InitStructure.DMA_PeripheralBaseAddr = DAC_DHR8R1_ADDRESS;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&Escalator8bit;
DMA_InitStructure.DMA_BufferSize = 6;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_Init(DMA2_Channel4, &DMA_InitStructure);
/* Enable DMA2 Channel4 */
DMA_Cmd(DMA2_Channel4, ENABLE);
/* Enable DAC1 Channel1: Once the DAC1 channel1 is enabled, PA.05 is
automatically connected to the DAC converter. */
DAC_Cmd(DAC1, DAC_Channel_1, ENABLE);
/* Enable DMA for DAC Channel1 */
DAC_DMACmd(DAC1, DAC_Channel_1, ENABLE);
截止到现在,这个错误还没被更正,在这里不知道会不会被他们看到;