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.

MSP430FR5994: 8-bit A/D readings

Part Number: MSP430FR5994


I need 8-bit values from the A/D converter.  Selecting 8-bit conversions returns more than 8 bits of data.

ADC12CTL2 |= ADC12RES_0;                // 8-bit conversion results

Is there another setting I'm missing?  Here is my setup code for the A15 input:

//init A/D

P3SEL1 |= BIT3; // Enable A/D channel A15
P3SEL0 |= BIT3;

PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode  to activate previously configured port settings

// By default, REFMSTR=1 => REFCTL is used to configure the internal reference
while(REFCTL0 & REFGENBUSY); // If ref generator busy, WAIT
REFCTL0 |= REFVSEL_0 | REFON; // Select internal ref = 1.2V
ADC12CTL0 = ADC12SHT0_2 | ADC12ON;
ADC12CTL1 = ADC12SHP; // ADCCLK = MODOSC; sampling timer
ADC12CTL2 |= ADC12RES_0; // 8-bit conversion results
ADC12MCTL0 |= ADC12INCH_15 | ADC12VRSEL_1; // A15 ADC input select; Vref=1.2V
while(!(REFCTL0 & REFGENRDY)); // Wait for reference generator to settle
ADC12CTL0 |= ADC12ENC; // Enable conversions

while(1)

{
ADC12CTL0 |= ADC12SC; // Start conversion-software trigger
while (!(ADC12IFGR0 & BIT0));
temp = ADC12MEM0; // Read conversion result -----> Reads > 8-bit values - need all answers to be from 00-FF.....

}

Thanks,

Don

  • Hi Don!

    Don Powrie said:
    ADC12CTL2 |= ADC12RES_0; // 8-bit conversion results

    This will not work as you want it to. ADC12RES in ADC12CTL2 is set to 10b after reset (14 bits). For 8 bits of resolution you must have 00b for ADC12RES. ADC12RES_0 will have 0 as definition, so when using |= as instruction, ADC12CTL2 will stay unchanged because ORing something with 0 has no effect. You have to clear bit 4 and 5 in ADC12CTL2 for 8 bits of resolution.

    You can a) write ADC12CTL2 &= ~(0x10 | 0x20); or b) initialize ADC12CTL2 completely by writing ADC12CTL2 = (ADC12RES_0 | ...); Since ADC12RES_0 is 0 you do not have to write this statement at all, but it is easiert to see that you have chosen setting _0.

    Dennis

  • That makes sense. I'll give it a try.

    Thank you for the super fast response!!

**Attention** This is a public forum