This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
程序如下:
初始化函数:
void SD24Init(void)
{
uint16_t i = 0;
SD24CTL = SD24REFON | SD24SSEL0 | SD24DIV_3;
SD24CCTL0 = (SD24SNGL | SD24GRP | /*SD24DF |*/
SD24LSBTOG);
SD24CCTL1 = (SD24SNGL | SD24GRP | /*SD24DF |*/
SD24LSBTOG);
SD24CCTL2 = (SD24SNGL | SD24IE | /*SD24DF |*/
SD24LSBTOG);
SD24INCTL0 |= SD24INCH_5;
SD24INCTL1 |= SD24INCH_6;
SD24INCTL2 |= SD24INCH_7;
for (i = 0; i < 0x3600; i++);
SD24CCTL2 |= SD24SC;
}
中断处理函数:
int32_t ConvData[3];
float SampValue[3];
#pragma vector=SD24_VECTOR
__interrupt void SD24AISR(void)
{
switch (SD24IV)
{
case 2:
break;
case 4:
break;
case 6:
break;
case 8:
ConvData[0] = SD24MEM0;
SD24CCTL0 |= SD24LSBACC;
ConvData[1] = SD24MEM1;
SD24CCTL1 |= SD24LSBACC;
ConvData[2] = SD24MEM2;
SD24CCTL2 |= SD24LSBACC;
ConvData[0] = (ConvData[0] << 16) + SD24MEM0;
SD24CCTL0 &= ~SD24LSBACC;
ConvData[1] = (ConvData[1] << 16) + SD24MEM1;
SD24CCTL1 &= ~SD24LSBACC;
ConvData[2] = (ConvData[2] << 16) + SD24MEM2;
SD24CCTL2 &= ~SD24LSBACC;
SampValue[0] = 0.6 * ConvData[0] / (4194304);
SampValue[1] = 0.6 * ConvData[1] / (4194304);
SampValue[1] = SampValue[1] * 1000 / 1.32 - 273;
SampValue[2] = 0.6 * ConvData[2] / (4194304);
break;
}
}
IAR5.5 3个SD24通道分别采样 芯片模拟供电电压、内部温度传感器、PAG偏置,采用24位数据模式,单次转换,
但是得到结果却是完全不对,有人知道原因吗?是不是我的程序有什么问题?求指导
1、我用到高精度24位AD,我主要参考官方例程,发现MSP430F4270的例程中有过采样率1024的,但是只读出低十六位。我想用msp430afe253读出24位AD数应该怎么改造。
请把下面代码改造成msp430afe253的24位精度的例程。
2、下图是430指南的截图,我的问题是两次读取,重叠的部分怎么处理?
代码如下
MSP430F4270
// -----------------
// /|\| XIN|-
// | | | 32kHz
// --|RST XOUT|-
// | |
// Vin+ -->|A0+ |
// Vin- -->|A0- |
// | |
// | VREF |---+
// | | |
// | | -+- 100nF
// | | -+-
// | | |
// | AVss |---+
// | |
//
// L. Westlund / S. Karthikeyan
// Texas Instruments Inc.
// June 2005
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.30A
//*****************************************************************************
#include <msp430.h>
unsigned int result;
int main(void)
{
volatile unsigned int i; // Use volatile to prevent removal
// by compiler optimization
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP14PF; // Configure load caps
for (i = 0; i < 10000; i++); // Delay for 32 kHz crystal to
// stabilize
SD16CTL = SD16REFON+SD16SSEL0; // 1.2V ref, SMCLK
SD16CCTL0 |= SD16SNGL+SD16IE+SD16XOSR+SD16OSR0;// Single conv, enable interrupt, 1024 OSR
SD16INCTL0 |= SD16INTDLY_0; // Interrupt on 4th sample
for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup
_EINT(); // Enable general interrupts
while (1)
{
SD16CCTL0 |= SD16SC; // SET BREAKPOINT HERE
// Set bit to start conversion
_BIS_SR(LPM0_bits); // Enter LPM0
}
}
#pragma vector=SD16_VECTOR
__interrupt void SD16ISR(void)
{
switch (SD16IV)
{
case 2: // SD16MEM Overflow
break;
case 4: // SD16MEM0 IFG
result = SD16MEM0; // Save CH0 results (clears IFG)
break;
}
_BIC_SR_IRQ(LPM0_bits); // Exit LPM0
}
1、我用到高精度24位AD,我主要参考官方例程,发现MSP430F4270的例程中有过采样率1024的,但是只读出低十六位。我想用msp430afe253读出24位AD数应该怎么改造。
请把下面代码改造成msp430afe253的24位精度的例程。
2、下图是430指南的截图,我的问题是两次读取,重叠的部分怎么处理?
代码如下
MSP430F4270
// -----------------
// /|\| XIN|-
// | | | 32kHz
// --|RST XOUT|-
// | |
// Vin+ -->|A0+ |
// Vin- -->|A0- |
// | |
// | VREF |---+
// | | |
// | | -+- 100nF
// | | -+-
// | | |
// | AVss |---+
// | |
//
// L. Westlund / S. Karthikeyan
// Texas Instruments Inc.
// June 2005
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.30A
//*****************************************************************************
#include <msp430.h>
unsigned int result;
int main(void)
{
volatile unsigned int i; // Use volatile to prevent removal
// by compiler optimization
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP14PF; // Configure load caps
for (i = 0; i < 10000; i++); // Delay for 32 kHz crystal to
// stabilize
SD16CTL = SD16REFON+SD16SSEL0; // 1.2V ref, SMCLK
SD16CCTL0 |= SD16SNGL+SD16IE+SD16XOSR+SD16OSR0;// Single conv, enable interrupt, 1024 OSR
SD16INCTL0 |= SD16INTDLY_0; // Interrupt on 4th sample
for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup
_EINT(); // Enable general interrupts
while (1)
{
SD16CCTL0 |= SD16SC; // SET BREAKPOINT HERE
// Set bit to start conversion
_BIS_SR(LPM0_bits); // Enter LPM0
}
}
#pragma vector=SD16_VECTOR
__interrupt void SD16ISR(void)
{
switch (SD16IV)
{
case 2: // SD16MEM Overflow
break;
case 4: // SD16MEM0 IFG
result = SD16MEM0; // Save CH0 results (clears IFG)
break;
}
_BIC_SR_IRQ(LPM0_bits); // Exit LPM0
}