MSP430AFE的AD24怎样初始化和使用
Peter_Zheng:
举一个简单的例程参考吧
//*****************************************************************************
// MSP430AFE25x Demo – SD24, Continuous Conversion on a Group of 3 Channels
//
// Description: This program uses the SD24 module to perform continuous
// conversions on a group of channels (0, 1 and 2). A SD24 interrupt occurs
// whenever the conversions have completed. Test by applying voltages to the
// 3 input channels and setting a breakpoint at the line indicated
// below. Run program until it reaches the breakpoint, then use
// the debugger's watch window to view the conversion results. Results
// (upper 16 bits only) are stored in three arrays, one for each channel.
// ACLK = n/a, MCLK = SMCLK = DCO = ~ 1.1MHz
// //* For minimum Vcc required for SD24 module – see datasheet *//
// //* 100nF cap btw Vref and AVss is recommended when using 1.2V ref *//
//
// MSP430AFE25x
// —————–
// /|\| XIN|-
// | | |
// –|RST XOUT|-
// | |
// Vin1+ –>|A0.0+ |
// Vin1- –>|A0.0- |
// Vin2+ –>|A1.0+ |
// Vin2- –>|A1.0- |
// Vin3+ –>|A2.0+ |
// Vin3- –>|A2.0- |
// | VREF |—+
// | | |
// | | -+- 100nF
// | | -+-
// | | |
// | AVss |—+
// | |
//
// Naveen Kala
// Texas Instruments, Inc
// March 2011
// Built with IAR Embedded Workbench Version: 5.20.1
//*****************************************************************************
#include <msp430afe253.h>
#define Num_of_Results 8
/* Arrays to store SD24 conversion results */
unsigned int Ch0results[Num_of_Results];
unsigned int Ch1results[Num_of_Results];
unsigned int Ch2results[Num_of_Results];
void main(void)
{
volatile unsigned int i; // Use volatile to prevent removal
// by compiler optimization
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= BIT0+BIT1; // Set P1.0, P1.1 to output
SD24CTL = SD24REFON + SD24SSEL0; // 1.2V ref, SMCLK
SD24CCTL0 |= SD24GRP+SD24DF; // Group with CH1
SD24CCTL1 |= SD24GRP+SD24DF; // Group with CH2
SD24CCTL2 |= SD24IE+SD24DF; // Enable interrupt
for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup
SD24CCTL2 |= SD24SC; // Set bit to start conversion
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts
}
#pragma vector=SD24_VECTOR
__interrupt void SD24AISR(void)
{
static unsigned int index = 0;
switch (SD24IV)
{
case 2: // SD24MEM Overflow
break;
case 4: // SD24MEM0 IFG
break;
case 6: // SD24MEM1 IFG
break;
case 8: // SD24MEM2 IFG
Ch0results[index] = SD24MEM0; // Save CH0 results (clears IFG)
Ch1results[index] = SD24MEM1; // Save CH1 results (clears IFG)
Ch2results[index] = SD24MEM2; // Save CH2 results (clears IFG)
P1OUT ^=BIT0;
if (++index == Num_of_Results)
{
index = 0; // SET BREAKPOINT HERE
P1OUT ^=BIT1;
}
break;
}
}
Hardy Hu:
楼主可以使用Peter_Zheng给的例程先跑一下,然后根据自己的需求进行AD24的配置修改,设计自己的应用,需要用的文档资料有msp430afe2X3 datasheet,msp430X2XX user's guide(重点看SD24_A部分)
guiliang cui:
回复 Hardy Hu:
您好 ,请问那里有peter_zheng的例程啊 谢谢
guiliang cui:
回复 Hardy Hu:
就是上面那个哦,谢了。请问MSP430AFE2xx的开发板有吗?
guiliang cui:
回复 Hardy Hu:
请问有MSP430AFE2XX的开发板吗?谢谢
Lina Lian:
回复 guiliang cui:
guiliang cui,
例程可在此链接:http://www.ti.com/product/msp430afe253 的software 下载“MSP430AFE2x3, MSP430AFE2x2, MSP430AFE2x1 Code Examples”。
另外,上面链接在其 software & tool 部分有socket board:MSP430AFE2xx 16 Bit Microcontroller 24-Pin Socket Target Board;
Application note部分有很多应用手册可供参考!
希望对你有帮助!
BR,
Lina
guiliang cui:
回复 Lina Lian:
非常感谢、、、如果我购买socket board:MSP430AFE2xx 16 Bit Microcontroller 24-Pin Socket Target Board;,有没有各个模块的例程喃?
guiliang cui:
回复 Lina Lian:
谢谢、、
Lina Lian:
回复 guiliang cui:
guiliang cui,
其实socket board就是只有最基本的电路(JTAG, LED),并将所有管脚引出来而已,你可以看看socket board的电路图。在此链接对应文档的P43:http://www.ti.com.cn/cn/lit/ug/slau278p/slau278p.pdf
而各个模块的例程code example中都有了。
BR,
Lina
peipei li:
回复 Lina Lian:
Lina, 您好,我最近购买了TI的MSP430AFE253产品,并使用其内部的SD24模块做了一个24位的AD采集模块。我将数据输出方式按照手册上写的配置位2’s complement 方式(datasheet P625),当我输入为正电压时转换结果正确,即和数据手册描述的输出一样,可是当我输入为负电压时,输出就很大,比如,输入-0.6v,理论上应该是输出800000H,可是输出却远远大于800000H,不知道是为啥,我的配置是SD24DF=1,SD24UIN=0,请求您的帮助,谢谢!