dac.h文件只有一些声明,下面直接开始介绍dac.c的程序,本实验的DAC以及DMA的初始化,我们用到dac_dma_wave_init函数,该函数将DAC、TIM7的初始化部分都整合到一起了,其定义如下: 1 DAC_HandleTypeDef g_dac_dma_handle; /* DAC句柄 */ 2 DMA_HandleTypeDef g_dma_dac_handle; /* DMA句柄 */ 3 /** 4 *...
DMA_InitTypeDef DMA_INIT; DAC_INIT.DAC_Trigger=DAC_Trigger_T6_TRGO; DAC_INIT.DAC_WaveGeneration=DAC_WaveGeneration_None; DAC_INIT.DAC_OutputBuffer=DAC_OutputBuffer_Enable; DAC_Init(DAC_Channel_1,&DAC_INIT); DMA_DeInit(DMA1_Stream5); DMA_INIT.DMA_Channel=DMA_Channel_7; DMA_INIT.DMA_Per...
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); DMA_Cmd(DMA2_Channel3, ENABLE); D...
g_Wave1[i] = dac; } dac1_InitForDMA((uint32_t)&g_Wave1, 128, _freq * 128); } 正弦波输出128个采样点代表一个周期,同时程序里面增加了一个幅值设置功能,范围0到4095。实际DAC输出的波形频率由前面第2步函数 dac1_InitForDMA实现。比如我们要实现频率10KHz,幅值4095正弦波,那么配置就是:dac1_Set...
DMA_Init(DMA2_Channel3, &DMA_InitStructure); DMA_Cmd(DMA2_Channel3, ENABLE); DMA_ITConfig(DMA2_Channel3,DMA_IT_TC,ENABLE); } 注意红色字体写的那行代码,当我们传输多个数据时,需要将其设置为连续转换!其余就不赘述了。 接下来谈谈DAC固定电压的配置。
DAC_InitType.DAC_WaveGeneration=DAC_WaveGeneration_None;//不使用波形发生 DAC_InitType.DAC_LFSRUnmask_TriangleAmplitude=DAC_LFSRUnmask_Bit0;//屏蔽、幅值设置 DAC_InitType.DAC_OutputBuffer=DAC_OutputBuffer_Disable ; //DAC1输出缓存关闭 BOFF1=1 ...
DAC_DMACmd(DAC_Channel_1, ENABLE); //使能DAC通道1的DMA } /***定时器初始化***/ void SineWave_TIM_Config(u32 Wave1_Fre) { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);//开时钟 TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); ...
位 7:6 WAVE1[1:0]:DAC 通道 1 噪声 / 三角波生成使能(DAC channel1 noise/triangle wave ...
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; DAC_Init(DAC_Channel_2, &DAC_InitStructure); DMA_DeInit(DMA1_Stream6); DMA_InitStructure.DMA_Channel = DMA_Channel_7; ...
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable; DAC_Init(DAC_Channel_1, &DAC_InitStructure); DMA_DeInit(DMA2_Channel3); DMA_InitStructure.DMA_PeripheralBaseAddr = DAC_DHR8R1_Address; ...