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.

MSP430F5529: Internal comparator B false positive

Part Number: MSP430F5529

Hi,

I am trying to measure battery voltage using the internal comparator B on MSP430F5529. I used the example code and set the reference voltage to negative terminal of Comp B at 2V and the supply connected to the positive terminal of Comp B, CB4 (P6.4). P1.6  is connected to CBOUT (output of comp B)  and I probed P1.6  with saleae. I observed that the CBOUT goes high for 1.946V supply and stays high (I expected this to be low). For my application 50mV difference in measurement would make a huge impact. 

How accurate is Comp B? Can anybody help me make this more accurate? If there's something missing can somebody please point me to that?

Code used:

#include <msp430.h>

int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= BIT6; // P1.6 output direction
P1SEL |= BIT6; // Select CBOUT function on P1.6/CBOUT

// Setup ComparatorB
CBCTL0 |= CBIPEN + CBIPSEL_4; // Enable V+, input channel CB4
CBCTL1 |= CBPWRMD_1; // normal power mode
CBCTL2 |= CBRSEL; // VREF is applied to -terminal
CBCTL2 |= CBRS_3+CBREFL_2; // R-ladder off; Bandgap voltage amplifier ON and generates 2.0V reference
CBCTL3 |= BIT4; // Input Buffer Disable @P6.4/CB4
CBCTL1 |= CBON; // Turn On ComparatorB

__delay_cycles(75); // delay for the reference to settle

__bis_SR_register(LPM4_bits); // Enter LPM4
__no_operation(); // For debug
}

Thanks,

  • Hi Avinash,

    Thanks for posting! This helps our our greater community that may have a similar question.

    I've looped in my team members on the back end and we will get back to you shortly.

    Best,
    Omid D.
  • Hi Avinash,

    Please note that the 2 V VREF+ is typically 1.98 V with min and max values of 1.95 and 2 V, respectively, at 3 V. Then given the total unadjusted error of 1.5% it is possible to see how the threshold could be hit at 1.946 V.

    Regards,
    Ryan
  • Hi Ryan,

    Thank you for the quick reply, since this is a possible behavior I would like to supply external voltage to one of the channels and pass it through the internal resistor ladder to generate the VREF. This would give me control to set different voltages as VREF other than what I could obtain by passing VCC, 1.5V, 2.0V and 2.5V to the ladder. Can you please let me know if this is possible? If yes, could please explain how?

    Thanks,
    Avinash
  • Section 32.2.6 of the User's Guide says:

    The voltage reference generator can generate a fraction of the device's VCC or of the voltage reference of the integrated precision voltage reference source.

    It is not possible to use an external VREF. (Only the ADC can be connected to external VREFs.)

  • Hi Avinash,

    Along with what Clemens has said, you can use the CBRS and CBREF0/1/L bits to customize the reference voltage. I suggest using a shared reference voltage of 2.5 V with the resistor ladder.

    Regards,
    Ryan
  • Thank you Ryan and Clemens for your support.

**Attention** This is a public forum