-
HK32F103VET6 DAC1 输出电压异常问题
voidDAC_Configuration(void){DAC_InitTypeDefDAC_InitStructure;GPIO_InitTypeDefGPIO_InitStructure;RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC,ENABLE);GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4;//GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AIN;//GPIO_Init(GPIOA,&GPIO_InitStructure);//A¶Ë¿Ú//DAC_DeInit();//DAC_Cmd(DAC_Channel_1,ENABLE);//DAC_StructInit(&DAC_InitStructure);//½«DAC_StructµÄÖµÉèΪĬÈÏDAC_InitStructure.DAC_Trigger=DAC_Trigger_Software;//ÓÉÈí¼þ´¥·¢DAC_InitStructure.DAC_WaveGeneration=DAC_WaveGeneration_None;//¹Ø±Õ²¨ÐÎÉú³ÉDAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude=DAC_TriangleAmplitude_4095;DAC_InitStructure.DAC_OutputBuffer=DAC_OutputBuffer_Enable;//ʹÄÜDACͨµÀ»º´æDAC_Init(DAC_Channel_1,&DAC_InitStructure);/*EnableDACChannel1*/DAC_Cmd(DAC_Channel_1,ENABLE);DAC_SetChannel1Data(DAC_Align_12b_R,4085);DAC_SoftwareTriggerCmd(DAC_Channel_1,ENABLE);while(1){DAC_SetChannel1Data(DAC_Align_12b_R,4085);DAC_SoftwareTriggerCmd(DAC_Channel_1,ENABLE);}源代码如上,输出电压不对,试过其他数值也不对,代码之前是用在ST上的
2021-07-30 0