在线时间0 小时
UID330519
ST金币0
蝴蝶豆0
注册时间2011-11-25
新手上路
- 最后登录
- 1970-1-1
|
a0a.1 0b0c
我想编一个关于DAC电压采集的程序 基准电压是3.3V 想测一下DAC输出脚的电压 并能够实时显示,用的是PA5脚(DAC_channel2),下面是我的程序 我是新手不太懂 希望高人指点下 谢谢了
#include "stm32f10x.h"
#include "stm32f10x_dac.h"
#define DAC_DHR12RD_Address 0x40007420
int main(void)
{
DAC_InitTypeDef DAC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
/* Configure DAC channel2 outputs pins */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
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_Enable;
DAC_Init(DAC_Channel_2, &DAC_InitStructure);
// DAC_SetChannel2Data(DAC_Align_12b_R, 0x000); //12位右对齐,输出一半的基准电压
// DAC_SoftwareTriggerCmd(DAC_Channel_2,ENABLE); //使能软件触发,更新DAC的值
DAC_Cmd(DAC_Channel_2, ENABLE);
}
如果能正确测得DAC电压,我想实时动态显示采得的电压,怎么做呢
|
|