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.
Hello everyone,
i am a beginner to ccs v4 and msp430 kit. please pardon my innocence in any minute details that has to be remembered.
I am trying to execute ADC project in ccs v4 using MSP430F6638IPZR kit with a MSP430 USB-Debug-Interface MSP-FET430UIF. the maximum software configurable supply voltage that this USB-Debug-Interface can handle is between 1.8 V to 3.6 V at 100 mA.
Fortunately the code has been successfully executed but we could not find the output. I am trying to read the output of the project in registers ADC12MEM0 as per the documents and information provided in TI forum. But the problem is the value in ADC12MEM0 change every time i run the project after debugging it. Following snapshot is
following is the snapshot where value in ADC12mem0 changed after running again.
the code for ADC project is
#include <msp430f6638.h>
int i;
long temp;
volatile long IntDegF;
volatile long IntDegC;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
REFCTL0 &= ~REFMSTR; // Reset REFMSTR to hand over control to
// ADC12_A ref control registers
ADC12CTL0 = ADC12SHT0_8 + ADC12REFON + ADC12ON;
// Internal ref = 1.5V
ADC12CTL1 = ADC12SHP; // enable sample timer
ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_10; // ADC i/p ch A10 = temp sense i/p
ADC12IE = 0x001; // ADC_IFG upon conv result-ADCMEMO
for(i=0;i<30;i++) // Delay to allow Ref to settle
ADC12CTL0 |= ADC12ENC;
while(1)
{
ADC12CTL0 &= ~ADC12SC;
ADC12CTL0 |= ADC12SC; // Sampling and conversion start
__bis_SR_register(LPM4_bits + GIE); // LPM0 with interrupts enabled
__no_operation();
// Temperature in Celsius
// ((A10/4096*1500mV) - 680mV)*(1/2.25mV) = (A10/4096*666) - 302
// = (A10 - 1858) * (666 / 4096)
IntDegC = ((temp - 1858) * 666) / 4096;
// Temperature in Fahrenheit
// Tf = (9/5)*Tc + 32
IntDegF = ((temp - 1858) * 1199) / 4096 + 32;
__no_operation(); // SET BREAKPOINT HERE
}
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
switch(__even_in_range(ADC12IV,34))
{
case 0: break; // Vector 0: No interrupt
case 2: break; // Vector 2: ADC overflow
case 4: break; // Vector 4: ADC timing overflow
case 6: // Vector 6: ADC12IFG0
temp = ADC12MEM0; // Move results, IFG is cleared
__bic_SR_register_on_exit(LPM4_bits); // Exit active CPU
case 8: break; // Vector 8: ADC12IFG1
case 10: break; // Vector 10: ADC12IFG2
case 12: break; // Vector 12: ADC12IFG3
case 14: break; // Vector 14: ADC12IFG4
case 16: break; // Vector 16: ADC12IFG5
case 18: break; // Vector 18: ADC12IFG6
case 20: break; // Vector 20: ADC12IFG7
case 22: break; // Vector 22: ADC12IFG8
case 24: break; // Vector 24: ADC12IFG9
case 26: break; // Vector 26: ADC12IFG10
case 28: break; // Vector 28: ADC12IFG11
case 30: break; // Vector 30: ADC12IFG12
case 32: break; // Vector 32: ADC12IFG13
case 34: break; // Vector 34: ADC12IFG14
default: break;
}
}
while debugging , executing the project we did not give any external analog input voltage to the target (msp430).
Do i need to give any external input voltage or will it be taken from the target(msp430) itself?
Please anyone help me with this query where i have been stuck for long time.
Thanks in advance.
Hi Tyler,
Thank you very much for your immediate response.
As per your suggestion,I could find the value in watch when i entered IntDegF .
After i debugged the project and ran it when i entered IntDegF in watch and press enter its showing me error and if i pause it after the value appears.
i don't know whether this is a minute detail or not pardon me for that how to know the whether value that appears in the watch expressions is CORRECT or NOT.
we got the value 114. Please find snap shot.
And in the previous comment given by you i did not completely understand the meaning of your last sentence which says " you can only view these when at a breakpoint.". If you don't mind can you please explain it.
Once again thank you so much for your help.
you can only view the values when the debug is paused(this is done automatically when your program encounters a breakpoint). these values are updated when your program is paused and if they changed from the last pause, they will be highlighted in yellow. this is the primary use for breakpoints. if you want to see the value of ADC10MEM, it will be in the Registers tab under ADC10. the program has to be in debug mode and the program has to be paused in order to see it.
I hope this clears things up,
Tyler
Hi Tyler,
I am very thankful for your response.
Here we got a value in the watch window for intdegF 111. we understood it is the temperature.
But my concern is,whether the expected output of the project is digital(binary).
And another small question is how to find the value of the address like ADC12MEM0 because in register ADC12MEM0 it is showing the address in ADC12MEM0 as 0x0855 but when we check same address in memory we could not find the the same address . is it the way to find value of the address or is there any other way.
following snap shot is memory and register windows
please pardon my innocence and thanks in advance.
ADC12MEM0 shows that the input value is 0x855 (0x means hex). this is equivalent to 2133 in base 10. if you don't like viewing these values in hex, right click on the value > number format > decimal . since you are using ADC12 the highest value is 4096 (2^12). which means you are receiving 2133/4096 = ~52%. this is what we would expect if the input pin were floating (not connected). therefore you find the pin voltage like this:
PIN_VOLTAGE = (INPUT_VALUE / 4096) * MICROCONTROLLER_VOLTAGE
so, if you power your microcontroller with 3.3V, the pin voltage is ~1.7V. as far as binary goes, nothing defaults to binary. all values are shown in decimal or hex (0x)
Hope this helps,
Tyler
Hi Tyler,
Thank you so much for your help,it helped to make the progress.
Thanks once again for sharing your knowledge.
Shilpa
Hi Tyler ,
Your explanation helped me very much and made me understand very basic and significant topics.
I successfully executed the program and got the values i.e temperature in f and c .But i want to know what was the input voltage as in your last post you have said that " if you power your microcontroller with 3.3V, the pin voltage is ~1.7V ". what do you mean by powering the micro controller. i assumed that it is external input voltage Vin . but i was confused to which pins in board do i have to give the input voltage to AVcc and AVss i.e pins 11 and 12 respectively or some other pins. check out following pin configuration of my controller.
i have been using the same code as shilpa used and is the value in ADC12MEM0 is my digital output voltage?
It would be very helpful if you or anyone can solve this problem as it have been stuck here from much time.
Thanks in advance.
man unit said:if you power your microcontroller with 3.3V, the pin voltage is ~1.7V ". what do you mean by powering the micro controller. i assumed that it is external input voltage Vin . but i was confused to which pins in board do i have to give the input voltage to AVcc and AVss i.e pins 11 and 12 respectively or some other pinsi have been using the same code as shilpa used and is the value in ADC12MEM0 is my digital output voltage?
The ADC output is relative to a reference voltage. The default reference voltage is the analog supply voltage AVcc. So each count in ADC12MEMx stands for 1/4095 of AVcc.
A value of 2047 in ADCMEM0 stands vor AVcc*2047/4095 on the input pin which calculates to ~1.65V when AVcc is 3.3V.
The input voltage must not exceed the reference voltage, or the result will latch up at 4095 (0x0FFF).
Besides AVcc, the MSP can also use one of its internal reference voltages (depending on MSP, 1.5V, 2.0V and 2.5V are available). For this, teh reference msu tbe enabled and its use must be configured in the ADC12MCTLx register.
So no, the value in ADC12MEM0 is not your voltage. It is a count for the number of fractions of the reference voltage that your input voltage corresponds to.
And yes, you must connect AVss and AVcc. These are separate pins to increase accuracy. AVcc shouldn't be directly conncted to DVcc. A 10 to 100 Ohms series resistor (more is better, if you don'T need any larger output currents, e.g. for a DAC) and a 100nF ceramic capacitor parallel to a 10µF Tantalum cap shoudl be place dbetween AVcc and AVss. THis removes any ripple on AVcc tha tmight be present on DVcc due to the clocked digital operation of the CPU core (or other influences). Best case, the connection between AVss and DVss is made directly at the power suuply entry.
AVss should be reouted as a separate trace to the reference point (GND pin of the power supply). Any current in the system causes a voltage drop on the GND trace (due to wire impedance). THis would make your GND reference point move slightly. Routing AVss on a different wire than normal GND keeps the currents away from this wire and the GND reference level stable.
However, if you don't care for some noise and reduced precision in the lower bits of the result, you can connect the AVcc and AVss to DVcc adn DVss. If you don't they are auto-connected internally through the clamp diodes, but this measn an internal voltage drop and therefore offset and gain errors in the result.
Hi michael,
Thank you so much for your answer it gave me good insight into the topic.
Please pardon my knowledge if it is very basic. In ADC program after successful execution where must be my output lies and what is it digital converted voltage ?
And am i be able to give any external input voltage using potentiometer from breadboard to the any pins to change the output votage (digital)?
Please pardon my innoncence .
Thanks in advance.
As long as the voltage does not exceed the microcontroller voltage. Also, depending on the microcontroller you use not all of the pins support ADC (for example, the msp430g2553 can only use the ADC on pins 1.0 to 1.7). If you are going to read voltage from an external source, make sure that all your grounds are connected. Otherwise your readings will be off.
Tyler
Hi michael,
I mean 3.3 V has been applied to target cant we know specifically what is the reference voltage for a target so that its input voltage can be deduced
Thank you
Analog voltages can be applied to any pin with an 'Ax' tag. Like Pin 1.6. The number determines the input channel to the ADC.
**Attention** This is a public forum