TI中文支持网
TI专业的中文技术问题搜集分享网站

F5529 ADC序列通道编程的问题

我写了一个5529ADC12序列通道多次采样然后显示到NOKIA5110上的程序,不知道为什么一直进不了WHILE(1){}  程序如下(5110的低层驱动我已经省去了,免得看着烦)

#include <msp430.h>
#include"5110.h"
#include"NumTable.h"
#include"type.h"

#define uchar unsigned char
#define uint unsigned int
#define Num_of_Results 8

unsigned int A0results[];
volatile unsigned int A1results[];
volatile unsigned int A2results[];
volatile unsigned int A3results[];
volatile unsigned int index = 0;
float A0,A1,A2,A3,m;
uint n,p,q;
uint DisBuff[4];

void ADC12_INIT()
{
P6SEL = 0x0F; // Enable A/D channel inputs
ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_8; // Turn on ADC12, extend sampling time
// to avoid overflow of results
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_3; // Use sampling timer, repeated sequence
ADC12MCTL0 = ADC12INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL1 = ADC12INCH_1; // ref+=AVcc, channel = A1
ADC12MCTL2 = ADC12INCH_2; // ref+=AVcc, channel = A2
ADC12MCTL3 = ADC12INCH_3+ADC12EOS; // ref+=AVcc, channel = A3, end seq.
ADC12IE = 0x08; // Enable ADC12IFG.3
ADC12CTL0 |= ADC12ENC; // Enable conversions
ADC12CTL0 |= ADC12SC; // Start convn – software trigger}

void main()
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P1DIR|=0xff; //P1口打开作为输出(液晶)
P2DIR|=BIT0; //P2.0口打开作为输出(液晶)
Lcd_Init();//5110初始化前面程序已省略
Lcd_Cls();//5110 CLEAR前面程序已省略

ADC12_INIT();
_EINT();
__no_operation(); // For debugger
while(1)
{
DisBuff[0] =p%10;
DisBuff[1] = p%100/10; //取十位数
DisBuff[2] = p%1000/100;//百位数
DisBuff[3] = p/1000;//千位
Lcd_Num_Write(DisBuff[3],0,1);//(这个是显示到5110上,我把5110的程序省了,免得你们看的烦,5110的程序是经过验证了的没问题)
Lcd_Num_Write(DisBuff[2],1,1);
Lcd_Num_Write(DisBuff[1],2,1);
Lcd_Num_Write(DisBuff[0],3,1); }
}

#pragma vector=ADC12_VECTOR

__interrupt void ADC12ISR (void)

{

// static unsigned int index = 0;

A0results[index] = ADC12MEM0; // Move A0 results, IFG is cleared

A1results[index] = ADC12MEM1; // Move A1 results, IFG is cleared

A2results[index] = ADC12MEM2; // Move A2 results, IFG is cleared

A3results[index] = ADC12MEM3; // Move A3 results, IFG is cleared

m=(3.3*A0results[index])/4095;//算出电压
n=(150*m)/(5-m);//算出电阻值
p=n;
}

jerrsin jerrsin:

你的传感器是怎么接的?

james may:

回复 jerrsin jerrsin:

我做的是一个建议测电阻的装置,直接分压测电阻,我直接的AD采集口,然后测他的电压,然后便可以测他的相对应的电阻。。。

james may:

回复 jerrsin jerrsin:

接的P6.0口(AD采集口)

赞(0)
未经允许不得转载:TI中文支持网 » F5529 ADC序列通道编程的问题
分享到: 更多 (0)