fdsp 28335 adcc与adcmirror中采样结果一样么

TMS320F28335内部包含12位AD转换器,其功能有:
具有内置(采样保持)S/H的12位ADC内核
模拟输入:0.0V至3.0V(高于3.0V的电压产生满刻度转换结果)。
快速转换率:在25MHzADC时钟12.5MSPS上时高达80ns
16个专用ADC通道。
每次采样/保持都有复用的8通道
自动定序功能在单次会话中可提供多达16次“自动转换”。可将每次转换编程为选择16个输入信道中的任何一个。
序列发生器可运行为2个独立的8态序列发生器,或作为1个较大的16态序列发生器(即2个级联的8态序列发生器)。
用于存储转换值的16个结果寄存器(可分别寻址)
– 输入模拟电压的数值源自:
当input&0时:digital value =0;
当0&input&3.0时:digital value =4096*(input analog voltage-ADCLO)/3;
当input&3.0时:digital value =4095;
作为转换开始(SOC)序列源的多个触发器
– S/W-软件立即启动
– ePWMM转换开始
– XINT2ADC转换开始
灵活的中断控制允许每个序列结束(EOS) 或每个其它EOS上的中断请求。
序列发生器可运行于“启/停”模式,从而实现多个“时序触发器”同步转换。
SOCA和SOCB触发器可独立运行在双序列发生器模式中。
采样保持(S/H)采集时间窗口具有独立的预分频控制。
要获得指定的ADC精度,正确的电路板布局非常关键。为尽可能达到最佳效果,引入ADCIN引脚的走线不应太靠近数字信号通道。这是为了最大程度地减少数字线路上因ADC输入耦合而产生的开关噪声。而且,适当的隔离技术必须被用来将数字电源从ADC模块电源引脚(VDD1A18,VDD2A18,VDDA2,VDDAIO)上隔离。
ADC未被使用,ADC连接
建议保持针对模拟电源引脚的连接,即便在ADC未被使用时也是如此。下面总结了如果ADC未在应用中使用,应该如何连接ADC引脚:
? VDD1A18/VDD2A18-连接至VDD
? VDDA2,VDDAIO-连接至VDDIO
? VSS1AGND/VSS2AGND,VSSA2,VSSAIO-连接至VSS
? ADCLO-连接至VSS
? ADCREFIN-连接至VSS
? ADCREFP/ADCREFM-连接一个100nF电容器至VSS
? ADCRESEXT-连接一个20k?电阻器(非常松散的耐受)至VSS。
? ADCINAn,ADCINBn-连接至VSS
当ADC未被使用时,为了达到节能的目的,请确保到ADC模块的时钟未被打开。
当在一个应用中使用ADC模块时,未使用的ADC输入引脚应被连接至模拟接地(VSS1AGND/VSS2AGND)
ADC头文件与寄存器对应解读:
struct ADCTRL1_BITS {& && &// bits&&description
& & Uint16&&rsvd1:4;& && && && && &// 3:0& &reserved
& & Uint16&&SEQ_CASC:1;& && &// 4& &&&Cascaded sequencer mode 级联序列模式
& & Uint16&&SEQ_OVRD:1;& &&&// 5& &&&Sequencer override&&序列发生器覆盖
& & Uint16&&CONT_RUN:1;& & // 6& &&&Continuous run 连续运行模式
& & Uint16&&CPS:1;& && && && && & // 7& &&&ADC core clock pre-scalar ADC核心时钟分频
& & Uint16&&ACQ_PS:4;& && && &// 11:8&&Acquisition window size采集窗口大小
& & Uint16&&SUSMOD:2;& && & // 13:12 Emulation suspend mode仿真挂起模式
& & Uint16&&RESET:1;& && && & // 14& & ADC reset ADC复位
& & Uint16&&rsvd2:1;& && && && &// 15& & reserved 保留
下面的联合体主要是为了解决对这个寄存器的控制,可以是整体赋值液可以是一位一位的赋值。
union ADCTRL1_REG {
& &Uint16& && && && && &
& &struct ADCTRL1_BITS& &
struct ADCTRL2_BITS {& && && && && && && &// bits&&description
& & Uint16&&EPWM_SOCB_SEQ2:1;& && &&&// 0& &&&EPWM compare B SOC mask for SEQ2&&增强PWM比较器B作为SEQ2的启动转换标志
& & Uint16&&rsvd1:1;& && && && && && && && && && & // 1& &&&reserved
& & Uint16&&INT_MOD_SEQ2:1;& && && && & // 2& &&&SEQ2 Interrupt mode&&SEQ2终端模式& && && && && &&&
& & Uint16&&INT_ENA_SEQ2:1;& && && && && &// 3& &&&SEQ2 Interrupt enable&&SEQ2中断使能
& & Uint16&&rsvd2:1;& && && && && && && && && && & // 4& &&&reserved
& & Uint16&&SOC_SEQ2:1;& && && && && && && & // 5& &&&Start of conversion for SEQ2 启动SEQ2转换
& & Uint16&&RST_SEQ2:1;& && && && && && && & // 6& &&&Reset SEQ2& &&&SEQ2复位
& & Uint16&&EXT_SOC_SEQ1:1;& && && && & // 7& &&&External start of conversion for SEQ1& && &&&序列1的外部转换启动
& & Uint16&&EPWM_SOCA_SEQ1:1;& && & // 8& &&&EPWM compare B SOC mask for SEQ1
& & Uint16&&rsvd3:1;& && && && && && && && && && &// 9& &&&reserved
& & Uint16&&INT_MOD_SEQ1:1;& && && && &// 10& & SEQ1 Interrupt mode
& & Uint16&&INT_ENA_SEQ1:1;& && && && & // 11& & SEQ1 Interrupt enable
& & Uint16&&rsvd4:1;& && && && && && && && && &&&// 12& & reserved
& & Uint16&&SOC_SEQ1:1;& && && && && && &&&// 13& & Start of conversion trigger for SEQ1
& & Uint16&&RST_SEQ1:1;& && && && && && &&&// 14& & Restart sequencer 1& &
& & Uint16&&EPWM_SOCB_SEQ:1;& && & // 15& & EPWM compare B SOC enable
struct ADCASEQSR_BITS {& && & // bits& &description
& & Uint16&&SEQ1_STATE:4;& &&&// 3:0& & SEQ1 state& &序列1的状态
& & Uint16&&SEQ2_STATE:3;& &&&// 6:4& & SEQ2 state& &序列2的状态
& & Uint16&&rsvd1:1;& && && & // 7& && &reserved
& & Uint16&&SEQ_CNTR:4;& && & // 11:8& &Sequencing counter status& &序列计数器状态
& & Uint16&&rsvd2:4;& && && & // 15:12&&reserved&&
ADC最大转换信道数寄存器
struct ADCMAXCONV_BITS {& && &// bits&&description
& & Uint16&&MAX_CONV1:4;& && &// 3:0& &Max number of conversions& &序列1最大转换通道数
& & Uint16&&MAX_CONV2:3;& && &// 6:4& &Max number of conversions& & 序列2最大转换通道数
& & Uint16&&rsvd1:9;& && && & // 15:7&&reserved&
ADC信道选择排序控制寄存器
SEQ1只能使用ADCCHSELSEQ1和ADCCHSELSEQ2;AEQ2只能使用ADCCHSELSEQ3和ADCCHSELSEQ4
struct ADCCHSELSEQ1_BITS {& & // bits& &description
& & Uint16&&CONV00:4;& && && &// 3:0& & Conversion selection 00
& & Uint16&&CONV01:4;& && && &// 7:4& & Conversion selection 01
& & Uint16&&CONV02:4;& && && &// 11:8& &Conversion selection 02
& & Uint16&&CONV03:4;& && && &// 15:12&&Conversion selection 03
struct ADCCHSELSEQ2_BITS {& & // bits& &description
& & Uint16&&CONV04:4;& && && &// 3:0& & Conversion selection 04
& & Uint16&&CONV05:4;& && && &// 7:4& & Conversion selection 05
& & Uint16&&CONV06:4;& && && &// 11:8& &Conversion selection 06
& & Uint16&&CONV07:4;& && && &// 15:12&&Conversion selection 07
struct ADCCHSELSEQ3_BITS {& & // bits& &description
& & Uint16&&CONV08:4;& && && &// 3:0& & Conversion selection 08
& & Uint16&&CONV09:4;& && && &// 7:4& & Conversion selection 09
& & Uint16&&CONV10:4;& && && &// 11:8& &Conversion selection 10
& & Uint16&&CONV11:4;& && && &// 15:12&&Conversion selection 11
struct ADCCHSELSEQ4_BITS {& & // bits& &description
& & Uint16&&CONV12:4;& && && &// 3:0& & Conversion selection 12
& & Uint16&&CONV13:4;& && && &// 7:4& & Conversion selection 13
& & Uint16&&CONV14:4;& && && &// 11:8& &Conversion selection 14
& & Uint16&&CONV15:4;& && && &// 15:12&&Conversion selection 15
控制寄存器3
struct ADCTRL3_BITS {& && && &// bits& &description
& & Uint16& &SMODE_SEL:1;& &&&// 0& && &Sampling mode select&&采样模式选择
& & Uint16& &ADCCLKPS:4;& && &// 4:1& & ADC core clock divider&&ADC时钟分频器
& & Uint16& &ADCPWDN:1;& && & // 5& && &ADC powerdown& & ADC断电???
& & Uint16& &ADCBGRFDN:2;& &&&// 7:6& & ADC bandgap/ref power down&&ADC参考/带隙断电&&???
& & Uint16& &rsvd1:8;& && && &// 15:8& &reserved
状态寄存器
struct ADCST_BITS {& && && &&&// bits& &description
& & Uint16& &INT_SEQ1:1;& && &// 0& && &SEQ1 Interrupt flag& &序列1中断标志
& & Uint16& &INT_SEQ2:1;& && &// 1& && &SEQ2 Interrupt flag& &序列2中断标志
& & Uint16& &SEQ1_BSY:1;& && &// 2& && &SEQ1 busy status& && &序列1忙标志
& & Uint16& &SEQ2_BSY:1;& && &// 3& && &SEQ2 busy status& &&&序列2忙标志
& & Uint16& &INT_SEQ1_CLR:1;&&// 4& && &SEQ1 Interrupt clear&&清除序列1中断标志
& & Uint16& &INT_SEQ2_CLR:1;&&// 5& && &SEQ2 Interrupt clear&&清除序列2中断标志
& & Uint16& &EOS_BUF1:1;& && &// 6& && &End of sequence buffer1& &序列缓冲器1结束
& & Uint16& &EOS_BUF2:1;& && &// 7& && &End of sequence buffer2
& & Uint16& &rsvd1:8;& && && &// 15:8& &reserved
struct ADCREFSEL_BITS {& && & // bits& &description
Uint16& &rsvd1:14;& && &&&// 13:0& &reserved&&
Uint16& &REF_SEL:2;& && & // 15:14&&Reference select& &参考选择???
struct ADCOFFTRIM_BITS{& && & // bits& &description
int16 OFFSET_TRIM:9;& & // 8:0& & Offset Trim& &偏移微调???
Uint16 rsvd1:7;& && && & // 15:9& &reserved
struct ADC_REGS {
& & union&&ADCTRL1_REG& && & ADCTRL1;& && && && && && & // ADC Control 1
& & union&&ADCTRL2_REG& && & ADCTRL2;& && && && && && & // ADC Control 2
& & union&&ADCMAXCONV_REG& & ADCMAXCONV;& & // Max conversions
& & union&&ADCCHSELSEQ1_REG&&ADCCHSELSEQ1;&&// Channel select sequencing control 1
& & union&&ADCCHSELSEQ2_REG&&ADCCHSELSEQ2;&&// Channel select sequencing control 2
& & union&&ADCCHSELSEQ3_REG&&ADCCHSELSEQ3;&&// Channel select sequencing control 3
& & union&&ADCCHSELSEQ4_REG&&ADCCHSELSEQ4;&&// Channel select sequencing control 4
& & union&&ADCASEQSR_REG& && & ADCASEQSR;& && &&&// Autosequence status register
& & Uint16& && && && && &&&ADCRESULT0;& & // Conversion Result Buffer 0
& & Uint16& && && && && &&&ADCRESULT1;& & // Conversion Result Buffer 1
& & Uint16& && && && && &&&ADCRESULT2;& & // Conversion Result Buffer 2
& & Uint16& && && && && &&&ADCRESULT3;& & // Conversion Result Buffer 3
& & Uint16& && && && && &&&ADCRESULT4;& & // Conversion Result Buffer 4
& & Uint16& && && && && &&&ADCRESULT5;& & // Conversion Result Buffer 5
& & Uint16& && && && && &&&ADCRESULT6;& & // Conversion Result Buffer 6
& & Uint16& && && && && &&&ADCRESULT7;& & // Conversion Result Buffer 7
& & Uint16& && && && && &&&ADCRESULT8;& & // Conversion Result Buffer 8
& & Uint16& && && && && &&&ADCRESULT9;& & // Conversion Result Buffer 9
& & Uint16& && && && && &&&ADCRESULT10;& &// Conversion Result Buffer 10
& & Uint16& && && && && &&&ADCRESULT11;& &// Conversion Result Buffer 11
& & Uint16& && && && && &&&ADCRESULT12;& &// Conversion Result Buffer 12
& & Uint16& && && && && &&&ADCRESULT13;& &// Conversion Result Buffer 13
& & Uint16& && && && && &&&ADCRESULT14;& &// Conversion Result Buffer 14
& & Uint16& && && && && &&&ADCRESULT15;& &// Conversion Result Buffer 15
& & union&&ADCTRL3_REG& && &ADCTRL3;& && & // ADC Control 3&&
& & union&&ADCST_REG& && && & ADCST;& && && &// ADC Status Register
& & Uint16& && && && && &&&rsvd1;
& & Uint16& && && && && &&&rsvd2;
& & union&&ADCREFSEL_REG& && &ADCREFSEL;& && &// Reference Select Register
& & union&&ADCOFFTRIM_REG& &ADCOFFTRIM;& & // Offset Trim Register
struct ADC_RESULT_MIRROR_REGS
& & Uint16& && && && && &&&ADCRESULT0;& & // Conversion Result Buffer 0
& & Uint16& && && && && &&&ADCRESULT1;& & // Conversion Result Buffer 1
& & Uint16& && && && && &&&ADCRESULT2;& & // Conversion Result Buffer 2
& & Uint16& && && && && &&&ADCRESULT3;& & // Conversion Result Buffer 3
& & Uint16& && && && && &&&ADCRESULT4;& & // Conversion Result Buffer 4
& & Uint16& && && && && &&&ADCRESULT5;& & // Conversion Result Buffer 5
& & Uint16& && && && && &&&ADCRESULT6;& & // Conversion Result Buffer 6
& & Uint16& && && && && &&&ADCRESULT7;& & // Conversion Result Buffer 7
& & Uint16& && && && && &&&ADCRESULT8;& & // Conversion Result Buffer 8
& & Uint16& && && && && &&&ADCRESULT9;& & // Conversion Result Buffer 9
& & Uint16& && && && && &&&ADCRESULT10;& &// Conversion Result Buffer 10
& & Uint16& && && && && &&&ADCRESULT11;& &// Conversion Result Buffer 11
& & Uint16& && && && && &&&ADCRESULT12;& &// Conversion Result Buffer 12
& & Uint16& && && && && &&&ADCRESULT13;& &// Conversion Result Buffer 13
& & Uint16& && && && && &&&ADCRESULT14;& &// Conversion Result Buffer 14
& & Uint16& && && && && &&&ADCRESULT15;& &// Conversion Result Buffer 15
ADC_Cal()常规步骤:
第一步:这个是TI公司提供的文件
.def _ADC_cal& && && && && && && && && && && && && && && && && && &;定义代码段名称
.asg &0x711C&, ADCREFSEL_LOC& && && && && && && && & ;ADCREFSEL_LOC 是 ADC Reference Select Register, 地址0x711C&
.sect&.adc_cal&
MOVW DP, #ADCREFSEL_LOC && 6& && &&&;此时 DP = 0x7100&
MOV @28, #0xAAAA& && && && && && && && && && &&&;地址 : 0x7100 + 28
MOV @29, #0xBBBB& && && && && && && && && && && &;地址 : 0x7100 + 29
第二步:为 ADC_Cal() 添加命令文件&
ADC_CAL : origin = 0x380080, length = 0x000009
.adc_cal : load = ADC_CAL, PAGE = 0, TYPE = NOLOAD
第三步:在使用ADC前要声明ADC_Cal(),并且在使用ADC_Cal()之前要使能ADC高速时钟。
extern void ADC_cal(void);
EALLOW;& && && && && && && && && && && && && && && && && && &//允许对受保护的寄存器进行操作
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;&&//使能时钟
ADC_cal();& && && && && && && && && && && && && && && && && &&
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 0;&&//关闭时钟
EDIS;& && && && && && && && && && && && && && && && && && && && &//禁止对受保护的寄存器进行操作
ADC转换软件步骤:
初始化DSP系统;&&
设置PIE 中断矢量表,&
初始化ADC模块;&
将ADC中断的入口地址装入PIE 中断矢量表中,开中断;&
软件启动ADC转换;&
等待ADC中断;&
在ADC中断中读取ADC转换结果,软件启动下一次ADC中断。
本文已收录于以下专栏:
相关文章推荐
CONV_RUN为1时,无限次的会自动转换MAX_CONVn次,同时会把排序指针指向CONV00/08处,并重新开始;若为0时,每次触发转换MAX_CONVn次,但是指针不会自动指向CONV00/08...
TMS320F28335内部包含12位AD转换器,其功能有:
具有内置(采样保持)S/H的12位ADC内核
模拟输入:0.0V至3.0V(高于3.0V的电压产生满刻度转换结果)。
快速转换率:在...
使用TI 28335和片外AD7606,一个AD有8个通道可以采集,激活AD采集:
#define EXTADLZ0
*(int *)0x4200
// Zone 0, ADC data, A...
配置了三种模式,为单次模式,连续模式和DMA传输
单次模式是调用一次采集函数,在指定的某一个AD端口采集,用到的时候在去采样
连续模式是连续转换多个通道,采用级联模式,采用16路AD通道的值
两者存在差别,也有相同之处,还望斟酌查看
关于ADC这一块的功能基本上也算是CortexM芯片的标配了。ST的每一块芯片都有这个功能,只是说因型号不同,通道数、位数等有所不同。STM8的芯片大多数都是10的,也就是说分辨率可达到:参考...
#include "DSP28x_Project.h"Uint16 LoopC
Uint16 ConversionC
Uint16 Voltage1[10];
Uint16 Vol...
DMA(Direct Memory Access),即直接存储器存取,是一种快速传送数据的机制。它的优点在于一旦控制器初始化完成,数据开始传送,DMA就可以脱离CPU,独立完成数据传送。不需要依于CP...
他的最新文章
讲师:李江龙
讲师:司徒正美
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)【图文】TMS320F28335_adc模块讲解_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
TMS320F28335_adc模块讲解
大小:1.97MB
登录百度文库,专享文档复制特权,财富值每天免费拿!
你可能喜欢【第十二讲】TMS320F28335开发板之ADC模块
ADC模块:模拟-数字转换模块
首先为大家讲解ADC模块的硬件理论部分。
ADC实验注意事项:ADC的输入电压范围是0~3V,因此外部输入电压值一定不能超过这个范围~否则容易烧坏DSP芯片。
TMS320F2833x系列的ADC模块是一个12位具有流水线结构的模-数转换器,内置16通道,可配置为2个独立的8通道模块,每个模块对应一个排序器,共有两个排序器,但仅有一个转换器。两个独立的8通道模块也可以级联构成一个16通道模块,此时将自动构成一个16通道的排序器。
两个8通道模块能够完成自动排序功能,每个模块可通过多路选择器(MUX)选择8通道中的任何一个通道。在级联模式下,将自动构成一个16通道的排序器。对于每个通道而言,一旦ADC转换完成,将会把转换结果存储到结果寄存器(ACRESULT)中。自动排序器允许多同一个通道进行多次重复采样,用户可以执行过采样算法,这样与传统单一的采样转换结果相比可以获得更高的采样精度。
ADC模块主要包括以下特点:
带有两个采样/保持器(S/H)的12位模-数转换模块内核;
模拟输入电压范围:0~3V;
自动排序功能可一次性提供16通道&自动转换&,每次转换的通道可通过软件编程从16通道中任意选择;
快速转换功能,ADC时钟频率为12.5MHz时为6.25MSPS;
同步或顺序采样模式;
16个结果寄存器存放ADC转换后的结果,转换后的数字量表示为
模拟输入&=0
V&(一般禁止)&
& & 数字值=0
0V & 模拟输入 &3V &
& & (十进制数) 数字值=4096 *
(输入模拟电压值 - ADCLO)/3 &
&ADCLO引脚一般接地 ADCLO=0
模拟输入&=3V
&(一般禁止)&&
& &数字值=4095
有多个触发源启动ADC模块转换(SOC):S/W软件立即启动、ePWM1~6、GPIO XINT2;
灵活的中断控制,允许每个或每隔一个序列转换结束产生中断请求;
在双排序器模式下,ePWM触发器可以独立工作;
采样保持(S/H)采集时间窗口有独立的预定标控制。
下面针对上面的功能框图中的各个模块功能进行介绍:
ADC排序器由两个独立的8状态排序器(SEQ1和SEQ2)构成,这两个排序器还可以级联构成16状态排序器(SEQ)。简单理解排序器的用途就是通过人为软件编程来规定18通道模拟量输入的每个通道的转换顺序。当接收到开始转换信号之后,就自动按顺序进行转换,转换结果存放在相应的结果寄存器ADCRESULTn(其中第一个结果存放在ADCRESULT0,第二个存放在ADCRESULT1中,以此类推,第十六个结果存放在ADCRESULT15中)
为了方便,排序器状态由下列符号状态:
对于SEQ1,CONV00~CONV07;
对于SEQ2,CONV08~CONV15;
对于级联SEQ,CONV00~CONV15。
每个顺序变换的模拟输入通道由ADC模块输入通道选择序列控制寄存器ADCCHSELSEQn中的CONVnn位确定。各个模拟通道可以以任何次序进行选择,而且同一通道可以被多次选择。
& & 2.连续自动排序模式
以上就是该过程的流程图。
在8通道的排序器(SEQ1或SEQ2)模式下,SEQ1/SEQ2能在一次排序过程中对8个任意通道(级联模式时可达16通道)进行顺序转换。每次转换的结果保存在相应的结果寄存器(SEQ1为ADCRESULT0~ADCRESULT7,SEQ2的为ADCRESULT8~ADCRESULT15)中,这些寄存器由低地址向高地址依次被填充。
每个排序中的转换个数由MAX_CONVn(ADCMAXCONV寄存器中的一个3位或4位选择位)控制,该值在自动排序的转换开始时,被装载到自动排序状态寄存器(ADCASEQSR)的排序计数器控制位(SEQCNTR[3:0])。MAX_CONVn的值在0~7(级联模式下为0~15)范围内变化。当排序器从通道CONV00开始按顺序转换时,SEQ_CNTR的值从装载值开始向下计数,直到SEQ_CNTR等于0。一次自动排序完成的转换数为MAXCONVn+1.
假设在双排序模式下,使用SEQ1完成7次转换,分别是A2、A3、A2、A3、A6、A7、B4,则MAX_CONV1应设置成6,ADCCHSELSEQ1寄存器的CONV00~CONV03需分别配置为2、3、2、3,ADCCHSELSEQ2寄存器中的CONV04~CONV06需分别配置成6、7、12.排序器一旦接收到开始转换(SOC)触发信号,就开始转换,SOC触发信号也会装载SEQ_CNTR位。ADCCHSELSEQn寄存器中指定的通道按规定的顺序进行转换。每次转换完成后SEQ_CNTR位自动减1,一旦SEQ_CNTR=0,根据寄存器ADCTRL1中连续运行状态位(CONT_RUN)的不同,会出现以下两种情况:
如果CONT_RUN置1,转换序列自动重新开始;
如果CONT_RUN没有被置位,排序器指针停留在最后状态,SEQ_CNTR继续保持0.为了在下一次启动时重复排序操作,在下一个SOC到来之前使用RST_SEQn来复位排序器(SEQ1复位为CONV00,SEQ2复位为CONV08)。
& & 3.ADC时钟模块
外设时钟HSPCLK通过HSPCP[2:0]寄存器对系统时钟SYSCLK分频得到,ADC模块是通过ADCTRL3寄存器的ADCCLKPS[3:0]位来对HSPCLK分频的,然后再通过寄存器ADCTRL1中的CPS位进行2分频或不分频,最后输出的就是ADC模块的时钟ADCCLK。另外,ADC模块能够通过增大采样/保持时间来适应信号源阻抗的变化,这是由ADCTRL1寄存器中的ACQ_PS[3:0]位控制的。这些位并不影响采样/保持和转换过程,但通过扩展转换脉冲的长度可以增加采样时间的长度。ADC模块的时钟电路结构如下图:
要注意的是,两个ADC时钟周期才能完成一次采样,ADC正常工作的时钟频率是25MHz,所以ADC的最高采样频率是12.5MHz。
鉴于HSPCLK时钟不仅仅被ADC模块使用,为了提高其他模块的工作性能,一般HSPCLK时钟频率不能过低。因此采用ADCTRL3寄存器的ADCCLKPS位对HSPCLK进行分频,从而得到ADC模块需要的任意时钟频率。
*4.ADC模块参考电压选择(默认采用内部供给)
*5.低功耗模式&
& & *6.ADC模块的校准
以上就是理论部分,有关于ADC模块的寄存器请大家参考相关手册
相关寄存器:
ADC控制寄存器ADCTRLx(1~3)、最大转换通道寄存器ADCMAXCONV、自动排序状态寄存器ADCASEQSR、ADC输入通道选择顺序控制寄存器ADCCHSELSEQx(1~4)、ADC结果寄存器ADCRESULTn(0~15)
*******************************************************************************************************************
下面是软件实验部分
1.Example_2833xAdcSeqModeTest.c【ADC模块在排序器模式下采样实验】
File $Revision: /main/10 $
Checkin $Date: April 21, :57 $
//###########################################################################
Example_2833xAdcSeqModeTest.c
DSP2833x ADC Seq Mode Test.
ASSUMPTIONS:
program requires the DSP2833x header files.
sure the CPU clock speed is properly defined in
DSP2833x_Examples.h before compiling this
Connect the signal to be converted to channel
supplied, this project is configured for "boot to
operation. The 2833x Boot Mode table is shown
information on configuring the boot mode of an
refer to the documentation included with the
$Boot_Table:
GPIO86 GPIO85 GPIO84
XA14 XA13 XA12
==========================================
1 Jump to Flash
0 SCI-A boot
1 SPI-A boot
0 I2C-A boot
1 eCAN-A boot
0 McBSP-A boot
1 Jump to XINTF x16
0 Jump to XINTF x32
1 Jump to OTP
0 Parallel GPIO I/O boot
1 Parallel XINTF boot
0 Jump to SARAM &- "boot to
1 Branch to check boot mode
0 Boot to flash, bypass ADC cal
1 Boot to SARAM, bypass ADC cal
0 Boot to SCI-A, bypass ADC cal
Boot_Table_End$
DESCRIPTION:
Channel A0 is converted forever and logged in a buffer
(SampleTable)
memory window to SampleTable to observe the
for a while and stop and see the table contents.
Variables:
SampleTable - Log of converted values.
//###########################################################################
Original source by: S.S.
Release: DSP2833x/DSP2823x Header Files V1.20 $
$Release Date: August 1, 2008 $
//###########################################################################
#include "DSP28x_Project.h"
// Device Headerfile and Examples Include
start parameters
#define CPU_FRQ_150MHZ
(CPU_FRQ_150MHZ) // Default - 150 MHz SYSCLKOUT
#define ADC_MODCLK
0x3 // HSPCLK =
SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz 1.//对系统时钟进行分频获得HSPCLK(高速外设时钟信号)
默认未分频时HSPCLK=SYSCLK/2;
(CPU_FRQ_100MHZ)
#define ADC_MODCLK
0x2 // HSPCLK =
SYSCLKOUT/2*ADC_MODCLK2 = 100/(2*2) = 25.0 MHz
#define ADC_CKPS 0x3 // ADC module clock =
HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz 2.//对HSPCLK进行分频获得ADC模块时钟频率;
#define ADC_SHCLK
0xf // S/H width in ADC
module periods = 16 ADC clocks 3.//设置采样时间窗大小;
#define AVG 1000 // Average sample limit
4.//平均采样次数
#define ZOFFSET 0x00 // Average Zero
#define BUF_SIZE 2048 // Sample buffer
variable for this example
Uint16 SampleTable[BUF_SIZE];
1. Initialize System Control:
WatchDog, enable Peripheral Clocks
example function is found in the DSP2833x_SysCtrl.c
InitSysCtrl();
Specific clock setting for this example:
SysCtrlRegs.HISPCP.all = ADC_MODCLK; // HSPCLK = SYSCLKOUT/2*ADC_MODCLK 5.//高速外设时钟预分频器。具体HISPCP控制寄存器可以看相关手册,想查看HISPCP变量声明可右键&Open
Declaration&
2. Initialize GPIO:
example function is found in the DSP2833x_Gpio.c file
illustrates how to set the GPIO to it's default
InitGpio(); // Skipped for this example
3. Clear all interrupts and initialize PIE vector
Disable CPU interrupts
Initialize the PIE control registers to their default
default state is all PIE interrupts disabled and
function is found in the DSP2833x_PieCtrl.c
InitPieCtrl();
Disable CPU interrupts and clear all CPU interrupt
IER = 0x0000;
IFR = 0x0000;
Initialize the PIE vector table with pointers to the shell
Service Routines (ISR).
will populate the entire table, even if the
used in this example. This is useful for debug
shell ISR routines are found in
DSP2833x_DefaultIsr.c.
function is found in DSP2833x_PieVect.c.
InitPieVectTable();
4. Initialize all the Device Peripherals:
function is found in DSP2833x_InitPeripherals.c
InitPeripherals(); // Not required for this
InitAdc(); // For this example, init the ADC
Specific ADC setup for this example:
AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK; 6.//设置采样时间窗大小,此处ACQ_PS十进制15,采样时间窗大小=ADCLOCK*(15+1)
AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS; 7.//内核时钟分频,将HSPCLK进行分频获得ADC模块时钟频率
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; // 1
Cascaded mode 8.//采用级联运行模式
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0; 9.//初始化SEQ1通道指针
AdcRegs.ADCTRL1.bit.CONT_RUN = 1; // Setup
continuous run 10.//采用连续转换模式
5. User specific code, enable interrupts:
SampleTable
for (i=0; i&BUF_SIZE; i++)
SampleTable[i] =
0; 11.//清空数组SampleTable
AdcRegs.ADCTRL2.all = 0x2000; 12.//排序器1的启动转换触发(SOC)
ADC data and log the in SampleTable array
for (i=0; i&AVG; i++)
while (AdcRegs.ADCST.bit.INT_SEQ1== 0) {} // Wait for interrupt
13.//等待中断
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; 14.//SEQ1中断标志位清0
SampleTable[i] =((AdcRegs.ADCRESULT0&&4) );
15.//12位模数转换,数字结果最大(十进制)4095,对应输出12位,因此ADCRESULT0左移4位,只用低12位
//===========================================================================
//===========================================================================
我尽量将一些讲解写在了代码后面的注释中,希望大家结合具体实例好好理解。
这次由于没有实际输入模拟量,模拟量接口是悬空的,因此最终展示的输出数字结果(ADCRESULTn中的十进制数)是随机的,但是不会超过4095
需要观察的变量有SampleTable和AdcRegs.ADCRESULT0&&4,将它们分别加入&Add
Watch Expression&:
想要查看数组内的某个值:(只需改一下数组名,具体到某一个值)
2.Example_2833xAdcSeq_ovdTest.c【ADC模块在排序器覆盖模式下采样实验】
该实验代码和上一个有很大重叠,我只讲解一下【覆盖模式】这一部分的原理
File $Revision: /main/10 $
Checkin $Date: April 21, :51 $
//###########################################################################
Example_2833xAdcSeq_ovdTest.c
DSP2833x ADC Seq Override mode Test.
ASSUMPTIONS:
program requires the DSP2833x header files.
sure the CPU clock speed is properly defined in
DSP2833x_Examples.h before compiling this
Connect the signal to be converted to Channel
supplied, this project is configured for "boot to
operation. The 2833x Boot Mode table is shown
information on configuring the boot mode of an
refer to the documentation included with the
$Boot_Table:
GPIO86 GPIO85 GPIO84
XA14 XA13 XA12
==========================================
1 Jump to Flash
0 SCI-A boot
1 SPI-A boot
0 I2C-A boot
1 eCAN-A boot
0 McBSP-A boot
1 Jump to XINTF x16
0 Jump to XINTF x32
1 Jump to OTP
0 Parallel GPIO I/O boot
1 Parallel XINTF boot
0 Jump to SARAM &- "boot to
1 Branch to check boot mode
0 Boot to flash, bypass ADC cal
1 Boot to SARAM, bypass ADC cal
0 Boot to SCI-A, bypass ADC cal
Boot_Table_End$
DESCRIPTION:
Channel A0 is converted forever and logged in a buffer
(SampleTable)
sequencer1 in sequencer override mode. Sequencer is Sequential
sample rate of1/(3*40ns) =8.3MHz
memory window to SampletTable to observe the
for a while and stop and see the table contents.
Variables:
SampleTable - Log of converted values.
- Toggles on every ADC sequencer flag
//###########################################################################
Original source by: S.S.
Release: DSP2833x/DSP2823x Header Files V1.20 $
$Release Date: August 1, 2008 $
//###########################################################################
#include "DSP28x_Project.h"
// Device Headerfile and Examples Include
Determine when the shift to right justify the data takes
one of these should be defined as 1.
other two should be defined as 0.
#define POST_SHIFT
0 // Shift results after
the entire sample table is full
#define INLINE_SHIFT
1 // Shift results as
the data is taken from the results regsiter //
#define NO_SHIFT 0 // Do not shift the
start parameters
(CPU_FRQ_150MHZ) // Default - 150 MHz SYSCLKOUT
#define ADC_MODCLK
0x3 // HSPCLK =
SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
(CPU_FRQ_100MHZ)
#define ADC_MODCLK
0x2 // HSPCLK =
SYSCLKOUT/2*ADC_MODCLK2 = 100/(2*2) = 25.0 MHz
#define ADC_CKPS 0x0 // ADC module clock = HSPCLK/1 =
25.5MHz/(1) = 25.0 MHz
#define ADC_SHCLK
0x1 // S/H width in ADC
module periods = 2 ADC cycle
#define AVG 1000 // Average sample
#define ZOFFSET 0x00 // Average Zero
#define BUF_SIZE 1024 // Sample buffer
variable for this example
Uint16 SampleTable[BUF_SIZE];
Uint16 array_index;
1. Initialize System Control:
WatchDog, enable Peripheral Clocks
example function is found in the DSP2833x_SysCtrl.c
InitSysCtrl();
Specific clock setting for this example:
SysCtrlRegs.HISPCP.all = ADC_MODCLK; // HSPCLK = SYSCLKOUT/ADC_MODCLK
2. Initialize GPIO:
example function is found in the DSP2833x_Gpio.c file
illustrates how to set the GPIO to it's default
InitGpio(); // Skipped for this example
the pin GPIO34 as output
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // GPIO
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; //
Output pin
3. Clear all interrupts and initialize PIE vector
Disable CPU interrupts
Initialize the PIE control registers to their default
default state is all PIE interrupts disabled and
function is found in the DSP2833x_PieCtrl.c
InitPieCtrl();
Disable CPU interrupts and clear all CPU interrupt
IER = 0x0000;
IFR = 0x0000;
Initialize the PIE vector table with pointers to the shell
Service Routines (ISR).
will populate the entire table, even if the
used in this example. This is useful for debug
shell ISR routines are found in
DSP2833x_DefaultIsr.c.
function is found in DSP2833x_PieVect.c.
InitPieVectTable();
4. Initialize all the Device Peripherals:
function is found in DSP2833x_InitPeripherals.c
InitPeripherals(); // Not required for this
InitAdc(); // For this example, init the ADC
Specific ADC setup for this example:
AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK; // Sequential mode: Sample rate = 1/[(2+ACQ_PS)*ADC clock in
1/(3*40ns) =8.3MHz (for 150 MHz SYSCLKOUT)
1/(3*80ns) =4.17MHz (for 100 MHz SYSCLKOUT)
Simultaneous mode enabled: Sample rate = 1/[(3+ACQ_PS)*ADC clock in
AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS;
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; // 1
Cascaded mode
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;
AdcRegs.ADCTRL1.bit.CONT_RUN = 1; // Setup
continuous run
AdcRegs.ADCTRL1.bit.SEQ_OVRD = 1; //
Enable Sequencer override feature //使能排序器覆盖。当该位被置位后,最大转换通道数不受MAX_CONV限制。双排序器模式时,最大转换通道数始终是8,即相当于MAX_CONVn=0x07;级联模式时,最大转换通道数始终是16,即相当于MAX_CONVn=0x0f。该功能主要是为了方便控制最大转换通道数的转换,例如想在转换通道数6和16之间的切换只需要改变SEQ_OVRD即可,而无须改变SEQ_CASC和MAX_CONVn。
AdcRegs.ADCCHSELSEQ1.all = 0x0; //
Initialize all ADC channel selects to A0
AdcRegs.ADCCHSELSEQ2.all = 0x0;
AdcRegs.ADCCHSELSEQ3.all = 0x0;
AdcRegs.ADCCHSELSEQ4.all = 0x0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 0x7; //
convert and store in 8 results registers
5. User specific code, enable interrupts:
SampleTable
for (i=0; i&BUF_SIZE; i++)
SampleTable[i] =
AdcRegs.ADCTRL2.all = 0x2000;
// Take ADC data and log them in SampleTable
Initalize the array index. This points to the
location within the SampleTable
array_index = 0;
for (i=0; i&(BUF_SIZE/16);
while (AdcRegs.ADCST.bit.INT_SEQ1== 0){}
GpioDataRegs.GPBSET.bit.GPIO34 = 1; // Set
GPIO34 for monitoring -optional
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
INLINE_SHIFT
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT0)&&4); //
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT1)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT2)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT3)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT4)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT5)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT6)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT7)&&4);
#endif //--
INLINE_SHIFT
NO_SHIFT || POST_SHIFT
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT0));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT1));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT2));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT3));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT4));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT5));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT6));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT7));
#endif //-- NO_SHIFT ||
POST_SHIFT
while (AdcRegs.ADCST.bit.INT_SEQ1== 0){}
GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1; // Clear
GPIO34 for monitoring -optional
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
INLINE_SHIFT //
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT8)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT9)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT10)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT11)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT12)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT13)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT14)&&4);
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT15)&&4);
#endif //--
INLINE_SHIFT
NO_SHIFT || POST_SHIFT
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT8));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT9));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT10));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT11));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT12));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT13));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT14));
SampleTable[array_index++]= ( (AdcRegs.ADCRESULT15));
#endif // -- NO_SHIFT ||
POST_SHIFT
POST_SHIFT
post shifting, shift the ADC results
SampleTable buffer after the buffer is full.
for (i=0; i&BUF_SIZE; i++)
SampleTable[i] =
((SampleTable[i]) &&4);
#endif // --
POST_SHIFT
GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1; // Clear
GPIO34 for monitoring -optional
//===========================================================================
//===========================================================================
该实验主要是理解覆盖位的使用。在实例中设定的MAX_CONV=0x07,即最大转换通道是8.为了直观地看SEQ_OVRD的作用,我们监测ADCRESULT8和ADCRESULT15两变量的值。
具体检测方法如上一个实验,这里只展示结果:
1.SEQ_OVRD=1(覆盖模式)
2.SEQ_OVRD=0(不覆盖)注意修改程序后重新编译,然后重新加载!!!
**这里许多同学可能会遇到一个问题就是,SEQ_OVRD=0,编译重新加载后发现ADCRESULT8和ADCRESULT15仍有值,而不是0.其实有心的同学可能会发现,你重复运行和暂停程序,ADCRESULT8和ADCRESULT15这两个变量的值并没有变化,没有变红(常量不变红,变量变红)。之所以造成这种现象是因为,我们运行完SEQ_OVRD=1之后,ADCRESULT8和ADCRESULT15已经存了结果,而在运行SEQ_OVRD=0的程序前并没有将ADCRESULT复位,所以导致原来的值仍在ADCRESULT8和ADCRESULT15中,这时我们不必重启DSP开发板那么麻烦,只需:
找不到的同学可以在工具栏&Target&里面找到
3.Example_2833xAdcToDMA.c【ADC模块采样通过DMA传输数据实验】
&本实验的最终结果就是将ADCRESULT内的数据传输到DMA,我们只需监视DMA即可
这里就不上代码了,关于ADC模块部分代码上面都有解释,DMA模块代码以后会讲到,大家先了解一下,这里直接截取相关截图:
结果的数据不用太在意,因为模拟输入引脚悬空,这里的数据没有具体依据来确定,数据也不唯一。
4.Example_2833xAdcSoc.c【ADC模块触发SOC实验】
&这里采用的是ePWM_SOCA触发ADC,这部分在电机控制方面有很大应用,如果想深入研究,要学好ePWM模块部分。这部分我们要观察的实验现象就是观察ADCRESULT的值是否有变化,有变化则说明有ePWM信号产生,触发了ADC模块开始转换。下面只给出截图:
好啦,这一讲结束了,大家课后多花些时间加深理解,可以查看更多的实例,祝大家学习进步!尽快走进DSP的世界
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

我要回帖

更多关于 dsp28335 adc采样程序 的文章

 

随机推荐