微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > 射频无线通信设计 > MXCHIP+Core1081的ADC

MXCHIP+Core1081的ADC

时间:10-02 整理:3721RD 点击:


今天跑了下V1.19中 ADC的实验。将Analog Test Board 插入Open1081 的SPI口 。 (注:Analog Test Board 本身不带有ADC芯片,只是用于测试MCU自带的AD/DA功能 )





用MDK软件打开 ADC 的工程,配置,编译,下载运行



发现每隔一秒就会输出一个测量值,
用手旋转Analog Test Board上的电位器,串口输出 AD1 的采样值,同时Open1081 板上的4个用户LED 闪烁频率会相应改变。
······························································································································································
打开简单浏览了下V1.19中 ADC实验的main.c代码 ,发现MX1081 的 ADC 功能上手较容易。
关键代码:
·················
#define ADC1_DR_Address ((u32)0x4001204C) // 指定使用ADC1
··················
main()
{ ·····
ADC1_CH1_DMA_Config(); // 配置ADC1的参数 采用DMA模式
ADC_SoftwareStartConv(ADC1);// 启动ADC
·····
AD_value_1 = ADC_ConvertedValue[0]; //得到采样值的值
·····}

可以看出ST的库函数,已经把ADC 采样、转换 、传输等功能函数已经都编写好了,我们只需设置一下就可以正常使用了。
···························································································································································
突然对MX1081 的 ADC 有点兴趣,就查询MX1081的相关资料找到:






大概得出:MX1081 内部集成的STM32F205RG 内嵌3个12位的ADC,每个ADC共用8个外部通道。 STM32的ADC是逐次比较型ADC。
更多信息可以参看 stm32f2xx_adc.c

在STM32中,使用ADC时往往采用DMA传输方式,由DMA把ADC外设转换的数据传输到SRAM,再进行处理,甚至直接把ADC外设转换的数据转移到串口发送给上位机。

···············································································································
简单修改了下 main.c中代码,让其测电源压值 。
while(1)
{
/* Printf message with AD value to serial port every 1 second */
printf("\r\n****************************************************************\r\n");
AD_value_1 = ADC_ConvertedValue[0];
AD_value_1=(float) ADC_ConvertedValue[0]/4096*3.3;
printf("The current AD1 value = %f v\r\n",AD_value_1);
}

运行效果为:


Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top