i’m using msp430f149.i have one external battery,i want to measure it’s voltage range,and display it on lcd. somebody sait that we can use ADC,could you please guide me on this. i read msp430 user guide,but still now i didn’t get clear idea.i’m struggling how to take the value from msp .is there any formula is there?
The equation is on page 17-4 of the MSP430x1xx Family User’s Guide. Since you are using Avcc as Vr+ and Avss as Vr- ( SREF_0 ), the equation reduces down to
Nadc = 4095 * Vin / Vr+
rearranging
Vin = Nadc * Vr+ / 4095 or
Vin = Nadc * Avcc / 4095 as Vr+ is Avcc
It looks like your code is overwriting your ADC12CTL0, ADC12CTL1 and ADC12MCTL0 registers as you are using the ‘=’ rather then ‘|=’ when setting the various options.
thank you gm,i replaced |= insted of =,now i’m getting 4095…as you mentioned ndc=4095*vin/vr+;
vin=3.3 and vr+=1.3 ,then finally i’m getting 10395…what is this?this is my measured voltage?but i applied 5.5 only then how come this?could u please solve this issue…
The maximum recommended voltage on DVCC and AVCC is 3.6V. Absolute maximum is 4.1, beyond which permanent damage can occur. Maximum voltage applied to any pin is VCC + 0.3V. You have exceeded all of these. I will be surprised if your chip has not been damaged. You really need to read the data sheets and user guides.
i didn’t get your’s point.one thing sir i don’t fully about my development board,just i’m doing small small task.so tell me,now what i have to do?input channle o -voltage A0=3.3v ,this much only i’m giving,avcc and dvcc designed internally.please sir guide me on this
The ADC12 can only measure voltages between your negative reference (VR-, which is ground in your case) and your positive reference (VR+, which is AVCC in your case). To accurately measure a voltage on a input channel, you must ensure that the voltage will be between AVCC and ground.
It sounds like you need to use a voltage divider (2 resistors) to reduce the battery voltage to a value that can be read by the ADC.
Use resistor values that are high enough to minimise the battery drain, while low enough to minimise the error due to current drawn by the ADC input. If this is a problem, you could use an op-amp to drive the ADC input.