STM32F405功能优势
----------------------------------------
1、主频最高可达168MHz
2、3个12位AD,最高转换速度可达2.4MSPS
3、最高可达24通道,3通道同步采样可达7.2MSPS
DAC+DMA产生正弦信号程序配置
---------------------------------------------------------------
采用DMA循环传输模式,触发源为TIM2的 DAC_Trigger_T2_TRGO
本程序采用20个数据,2M的转换频率,产生100KHz的正弦信号
const uint16_t Sine12bit[20] =
{ 2681,3252,3705,3996,4095,3996,3705,3252,2681,
2048,1415,844 ,391,100, 0,100, 391 , 844, 1415,2048};
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable peripheral clocks ------------------------------------------------*/
/* GPIOA Periph clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
/* GPIOC Periph clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
/* DAC channel 1 & 2 (DAC_OUT1 = PA.4)(DAC_OUT2 = PA.5) configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
void DAC_Configuration(void)
{
DAC_InitTypeDef DAC_InitStructure;
/* DAC Periph clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
/* DAC channel1 Configuration */
DAC_InitStructure.DAC_Trigger = DAC_Trigger_T2_TRGO;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
/* Enable DAC Channel1: Once the DAC channel1 is enabled, PA.04 is
automatically connected to the DAC converter. */
DAC_Cmd(DAC_Channel_1, ENABLE)