Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Reads the MSP430 supply voltage using the Analog to Digital Converter (ADC).
- On ez430 boards, this is approx. 3600mV
- @return Vcc supply voltage, in millivolts
- */
- unsigned int getVcc3()
- {
- ADC10CTL0 = SREF_1 + REFON + REF2_5V + ADC10ON + ADC10SHT_3; // use internal ref, turn on 2.5V ref, set samp time = 64 cycles
- ADC10CTL1 = INCH_11;
- delayMs(1); // Allow internal reference to stabilize
- ADC10CTL0 |= ENC + ADC10SC; // Enable conversions
- while (!(ADC10CTL0 & ADC10IFG)); // Conversion done?
- unsigned long temp = (ADC10MEM * 5000l); // Convert raw ADC value to millivolts
- return ((unsigned int) (temp / 1024l));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement