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.

TLC1549

Other Parts Discussed in Thread: MSP430G2553, TLC1549

#include  <msp430g2553.h>

#define uchar unsigned char

unsigned int mi=0;

double ni;

unsigned int   adc(void)

{  unsigned int result=0;

int i;

P1OUT|=BIT1;

_delay_cycles(3);

P1OUT&=~BIT1;

for(i=0;i<10;i++)

{P1OUT&=~BIT2;

_delay_cycles(2);

result=((result<<1)+(P1IN&BIT3)/8);

_delay_cycles(1);

P1OUT|=BIT2;

_delay_cycles(4);

}

_delay_cycles(20);

P1OUT|=BIT1;

return (result);

}

void main(void)

{

WDTCTL = WDTPW +WDTHOLD;                  // Stop Watchdog Timer

P1DIR |= BIT1+BIT2;

while(1)

{

mi=adc();

ni=(mi)*(double)5/1024;

}

}

用TLC1549测稳压电压,怎么这个程序测得不准啊?而且值一直变,怎么回事啊?(BIT1是片选,BIT2是时钟,BIT3是数据输出)