I 'm testing the ADC12 module on msp430f5529 . I have a very simple program for debugging purpose. I'm setting the reference voltage to be 2.5V and the resolution is 12 bits. I'm expecting to see 0V~2.5V resulting in 0~4095. However any voltage input above around 1.45V will be converted as 1.45V. It seems there is a saturation somewhere. I'm not sure how to solve this problem. Help needed! Thanks. Here is my code: #include unsigned int test; int main(void) { WDTCTL = WDTPW+WDTHOLD; P6SEL |= 0x01; REFCTL0 &= ~REFMSTR; ADC12CTL0 = ADC12ON + ADC12SHT0_8 + ADC12REFON + ADC12REF2_5V; ADC12CTL1 = ADC12SHP + ADC12DIV_1; ADC12CTL2 = ADC12REFOUT + ADC12RES_2; ADC12MCTL0 = ADC12SREF_1; __delay_cycles(100); ADC12CTL0 |= ADC12ENC; // Enable conversions while (1) { ADC12CTL0 |= ADC12SC; // Start conversion while (!(ADC12IFG & BIT0)); test = ADC12MEM0; __no_operation(); // SET BREAKPOINT HERE } return 0; }
↧