- 帖子
- 304
- 主题
- 133
- 精华
- 16
- 积分
- 1000
- 来自
- 江西
- 在线时间
- 446 小时
- 注册时间
- 2007-5-28
|
STM32-PIN48脚的STM32F100C8T6B芯片的DA功能
STM32-PIN48脚的STM32F100C8T6B芯片的DA功能,已经调试成功。
下面是代码:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
DAC_DeInit();
DAC_Cmd(DAC_Channel_1,ENABLE);
DAC_Cmd(DAC_Channel_2, ENABLE);
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_InitStructure.DAC_Trigger = DAC_Trigger_Software;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_Noise;
DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bits8_0;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
*/
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
DAC_Init(DAC_Channel_2,&DAC_InitStructure);
/* Enable DAC Channel1 */
DAC_Cmd(DAC_Channel_1, ENABLE);
/* Enable DAC Channel2 */
DAC_Cmd(DAC_Channel_2, ENABLE);
//DAC_SetChannel2Data(DAC_Align_12b_R,0x7ff);//输出一半的基准电压
DAC_DualSoftwareTriggerCmd(ENABLE);//使能软件触发,更新DAC的值
大家可以参考。
针对的开发板类型如下图所示:
http://item.taobao.com/item.htm?id=7734619451
|
|