最近在工作中接触到TI的MSP430AFE2XX系列产品,搭建了一套测试用调试板,其实也非常简单,就是MSP430AFE2XX + LaunchPad + LCD,见下图
当然,MSP430AFE2XX芯片外围连接非常简单,VREF到AVSS之间接104电容,AVCC到AVSS之间加104电容,DVCC通过10R电阻到AVCC,RST 到DVCC 47K电阻,A0+,A0-输入端RC网络滤波;在调试过程中,人为接了一个桥模拟输入,在桥的一侧采用一个可变电阻+固定电阻,模拟信号量的改变,在测试中发现,采用USB端口供电是,ADC转换后的值后12位跳动比较厉害,后来将电源做了下调整,改用下图板上的电源,电路图如下
,将其正输出电源调整到6V左右,然后再接LDO输出3.3V供给AFE2XX芯片的DVCC,通过这个连接之后,发现ADC稳定了一些,以上ADC未做软件上的滤波处理,
我们期望的目的是24的ADC转换结果跳动的位数越少越好,各位看到的朋友请多多指点。
以下是测试用代码,
#include "io430.h"
#include "S6B0741.h"
//#include "msp430g2553.h"
#define LED_1 (0x01) // P1.0 LED output
#define LED_2 (0x40) // P1.6 LED output
#define RED_LED_ON() P1OUT |= (1<<0) //P1.0 led
#define RED_LED_OFF() P1OUT &= (~(1<<0))
#define RED_LED_COM() P1OUT ^= (1<<0)
#define Num_of_Results 10
#define FOSC 12000000
unsigned char HEX_ASCII[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
volatile unsigned char rec_data,rec_flag;
volatile unsigned char sec=0,min=0,hour=0;
unsigned int results,rest;
unsigned long sd24_result;
// Timer A0 interrupt service routine
#pragma vector=TIMER0_A0_VECTOR //TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
static unsigned char cnt=0;
if((++cnt)>=100)
{
cnt = 0;
if((++sec)>=60)
{
sec = 0;
if((++min)>=60)
{
min = 0;
if((++hour)>=24)
hour = 0;
}
}
}
}
/*************************************************************
系统时钟 初始化函数
************************************************************/
void SysCLK_init(void)
{
if (CALBC1_12MHZ==0xFF) // If calibration constant erased
{
while(1); // do not load, trap CPU!!
}
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_12MHZ; // Set DCO
DCOCTL = CALDCO_12MHZ;
//BCSCTL1 &= 0xCF;
// BCSCTL3 |= XCAP_3; //设置ACLK时钟源为32.768KHZ
}
/*************************************************************
TimerA初始化函数
************************************************************/
void TimeA_init(void)
{
CCTL0 |= CCIE; // CCR0 interrupt enabled
CCR0 = FOSC/8/100; //定时长为1S
TACTL |= TASSEL_2 + MC_1 + ID_3 ; //时钟 ACLK,Up to CCR0, SMCLK/8
}
/*************************************************************
UART 初始化函数
9600@12M 8N1
************************************************************/
/*
void Uart_init(void)
{
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2;
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 226; // 12MHz for 9600
UCA0BR1 = 4; // 12MHz for 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
}
*/
/*************************************************************
io端口 初始化函数
************************************************************/
void GPIO_init(void)
{
P1DIR |= LED_1 + LED_2; // P1.0 & P1.6 = LEDs
P1OUT = 0x00;
P2DIR |= ((1<<0)); //P20,P21,P22,P23用于驱动LCD
P1DIR |= ((1<<1)|(1<<3)|(1<<4)); //驱动LCD
}
/*************************************************************
SD24 初始化函数
************************************************************/
void SD24_init(void)
{
SD24CTL = SD24REFON + SD24SSEL0 + SD24XDIV_2; // + SD24DIV_2; // 1.2V ref, SMCLK
SD24INCTL0 = SD24INTDLY_1; // Interrupt on 3rd sample
//SD24CCTL0 |= SD24IE ; // SD24LSBTOG + Enable interrupt
//for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup
//SD24CCTL0 |= SD24SC; // Set bit to start conversion
}
#pragma vector=SD24_VECTOR
__interrupt void SD24AISR(void)
{
static unsigned int index = 0;
switch (SD24IV)
{
case 2: // SD24MEM Overflow
break;
case 4: // SD24MEM0 IFG
results = SD24MEM0; //高16位
SD24CCTL0 |= SD24LSBACC; //set bit SD24LSBACC to 1;
rest = SD24MEM0;
SD24CCTL0 &= ~SD24LSBACC;
break;
case 6: // SD24MEM1 IFG
break;
case 8: // SD24MEM2 IFG
//results = SD24MEM0; // Save CH2 results (clears IFG)
// if (++index == Num_of_Results)
// {
// index = 0; // SET BREAKPOINT HERE
// }
break;
}
}
unsigned long Get_SD24(unsigned int ch)
{
unsigned long long_temp;
SD24INCTL0 = SD24INTDLY_1 + ch;
SD24CCTL0 |= SD24SC;
while ((SD24CCTL0 & SD24IFG)==0);
SD24CCTL0 &= ~SD24SC;
results = SD24MEM0; //高16位
SD24CCTL0 |= SD24LSBACC; //set bit SD24LSBACC to 1;
rest = SD24MEM0;
SD24CCTL0 &= ~SD24LSBACC;
long_temp = (unsigned long)results;
long_temp <<= 8;
long_temp |= (unsigned long)rest;
return long_temp;
}
/***********************************************************
主函数
************************************************************/
int main( void )
{
unsigned char row;
float float_sd24;
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
SysCLK_init(); //系统时钟初始化函数
TimeA_init(); //TimerA初始化
//Uart_init(); //UART 初始化
GPIO_init(); //IO端口初始化
SD24_init();
__bis_SR_register(GIE); // Enter LPM0, interrupts enabled
lcd_init();
lcd_clr_all();
lcd_put_8x16_str_xy(0,0,"For AFE221 Test");
lcd_put_6x8_str_xy(0,14,"===================================");
lcd_put_6x8_str_xy(0,15,"Write By : AlexDeng");
row = 3;
lcd_put_6x8_str_xy(0,row,"TimeA UP to CCR0");
while(1)
{
//LCD显示 hour:Min:Sec
row = 4;
lcd_put_8x16_char_xy(0,row,HEX_ASCII[hour/10]);
lcd_put_8x16_char_xy(8,row,HEX_ASCII[hour%10]);
lcd_put_8x16_char_xy(16,row,':');
lcd_put_8x16_char_xy(24,row,HEX_ASCII[min/10]);
lcd_put_8x16_char_xy(32,row,HEX_ASCII[min%10]);
lcd_put_8x16_char_xy(40,row,':');
lcd_put_8x16_char_xy(48,row,HEX_ASCII[sec/10]);
lcd_put_8x16_char_xy(56,row,HEX_ASCII[sec%10]);
/*
row = 7;
lcd_put_8x16_char_xy(0,row,HEX_ASCII[(results>>12)&0x0f]);
lcd_put_8x16_char_xy(8,row,HEX_ASCII[(results>>8)&0x0f]);
lcd_put_8x16_char_xy(16,row,HEX_ASCII[(results>>4)&0x0f]);
lcd_put_8x16_char_xy(24,row,HEX_ASCII[results&0x0f]);
row = 7;
lcd_put_8x16_char_xy(40+0,row,HEX_ASCII[(rest>>12)&0x0f]);
lcd_put_8x16_char_xy(40+8,row,HEX_ASCII[(rest>>8)&0x0f]);
lcd_put_8x16_char_xy(40+16,row,HEX_ASCII[(rest>>4)&0x0f]);
lcd_put_8x16_char_xy(40+24,row,HEX_ASCII[rest&0x0f]);
*/
sd24_result = Get_SD24(SD24INCH_0);
row = 7;
lcd_put_8x16_char_xy(0,row,HEX_ASCII[(sd24_result>>20)&0x0f]);
lcd_put_8x16_char_xy(8,row,HEX_ASCII[(sd24_result>>16)&0x0f]);
lcd_put_8x16_char_xy(16,row,HEX_ASCII[(sd24_result>>12)&0x0f]);
lcd_put_8x16_char_xy(24,row,HEX_ASCII[(sd24_result>>8)&0x0f]);
lcd_put_8x16_char_xy(32,row,HEX_ASCII[(sd24_result>>4)&0x0f]);
lcd_put_8x16_char_xy(40,row,HEX_ASCII[sd24_result&0x0f]);
sd24_result = Get_SD24(SD24INCH_5);
sd24_result >>= 8;
sd24_result -= 0x8000;
//float_sd24 = sd24_result;
//float_sd24 *= 0.01831;
//float_sd24 *= 1200;
//sd24_result = (unsigned long)float_sd24;
//sd24_result *= 11;
//sd24_result *= 1200;
//sd24_result /= 0xffffff;
row = 9;
lcd_put_8x16_char_xy(0,row,HEX_ASCII[(sd24_result/10000%10)]);
lcd_put_8x16_char_xy(8,row,HEX_ASCII[(sd24_result/1000%10)]);
lcd_put_8x16_char_xy(16,row,HEX_ASCII[(sd24_result/100%10)]);
lcd_put_8x16_char_xy(24,row,HEX_ASCII[(sd24_result/10%10)]);
lcd_put_8x16_char_xy(32,row,HEX_ASCII[(sd24_result%10)]);
//lcd_put_8x16_char_xy(32,row,HEX_ASCII[(sd24_result/1000%10)]);
//lcd_put_8x16_char_xy(40,row,HEX_ASCII[(sd24_result/1000%10)]);
/*
lcd_put_8x16_char_xy(0,row,HEX_ASCII[(sd24_result>>20)&0x0f]);
lcd_put_8x16_char_xy(8,row,HEX_ASCII[(sd24_result>>16)&0x0f]);
lcd_put_8x16_char_xy(16,row,HEX_ASCII[(sd24_result>>12)&0x0f]);
lcd_put_8x16_char_xy(24,row,HEX_ASCII[(sd24_result>>8)&0x0f]);
lcd_put_8x16_char_xy(32,row,HEX_ASCII[(sd24_result>>4)&0x0f]);
lcd_put_8x16_char_xy(40,row,HEX_ASCII[sd24_result&0x0f]);
*/
}
}
POWER
LCD