本帖最后由 machonglin 于 2014-9-21 21:35 编辑
刚买的STM32F100C8T6B 48脚,PA4 DAC没有输出,哪位测试成功的,说说看呢 程序没改动,下到STM32F103RCT6上就有DAC输出 官网下的STM32F100C8T6B手册,写着有DAC功能,汗啊
网上搜了下,七嘴八舌的,有的说有DAC,有的说没有DAC,有没有权威一点的,究竟STM32F100C8T6B有没有DAC,如果没有,ST的手册害人啊,买了200片啊
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);
}
|