int main(void) { DAC_InitTypeDef DAC_InitType; GPIO_InitTypeDef GPIO_InitStructure; delay_init(); 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_Mode_AIN GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_ResetBits(GPIOA,GPIO_Pin_4) ;//PA.4 Êä³ö¸ß DAC_InitType.DAC_Trigger=DAC_Trigger_None; DAC_InitType.DAC_WaveGeneration=DAC_WaveGeneration_None;// DAC_InitType.DAC_LFSRUnmask_TriangleAmplitude=DAC_LFSRUnmask_Bit0; DAC_InitType.DAC_OutputBuffer=DAC_OutputBuffer_Disable ; DAC_Init(DAC_Channel_1,&DAC_InitType); DAC_Cmd(DAC_Channel_1, ENABLE); // DAC_DMACmd(DAC_Channel_1, ENABLE); // DAC_SetChannel1Data(DAC_Align_12b_R, 2000); while(1) { delay_ms(1000); DAC_SetChannel1Data(DAC_Align_12b_R, 0); delay_ms(1000); DAC_SetChannel1Data(DAC_Align_12b_R, 4096); } } |
评分
查看全部评分
adc 通道 就能用于dac
点评
ADC=DAC?
那 ,哪个芯片有DAC?ZET6 有吗?
STM32F051有
评分
查看全部评分
楼主如果能仔细阅读ST官方数据手册,就不会多走弯路了:
评分
查看全部评分
评分
查看全部评分