使用STM32F100C8T6B ,PA4 DAC没有输出,哪位测试成功的,说说看呢 声明下,程序没改动,下到STM32F103VCT6上就有DAC输出 官网下的STM32F100C8T6B手册,写着有DAC功能,汗啊
void DAC1_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
DAC_InitTypeDef DAC_InitStructure;
RCC_APB1PeriphClockCmd( RCC_APB1Periph_DAC, ENABLE );
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //使能PA端口时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; //DAC1 在 PA4
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
DAC_DeInit();
DAC_InitStructure.DAC_Trigger = DAC_Trigger_None;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
// DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
DAC_Cmd(DAC_Channel_1, ENABLE);
DAC_SetChannel1Data(DAC_Align_12b_R,2048); //12位 4096=3.3V 2048输出3.3/2=1.65V
DAC_SoftwareTriggerCmd(DAC_Channel_1,ENABLE);
}转载
|