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.

MSP430F133: ADC Sample program problems (fet140_adc12_01.c)

Part Number: MSP430F133

Hello, 

I built the sample ADC program fet140_adc12_01.c from the Resource Explorer to start to verify a new MSP430F133 based board.  The listing is below.  From the original example program, I added the P3 debug code since P3 is accessible from test points on the board.

When I compile and run the sample, I see about a 70us sawtooth pattern on the scope.  The pattern is strange in that it steps up from 3.2v to 3.8v.   Then there's a slow decay  (about 30us) from 3.8 back down to 3.2.  It stays at 3.2 for another 40us and then it steps back up to 3.8 to complete the cycle.  It is very repeatable. 

I figured that the step to 3.8v is the P3OUT |= 0x01 in the main loop prior to starting the ADC sampling.   

To test some timing I added a delay loop in the main.  It is the for (... 36000..) loop that is commented out in the code below.  I figured it would simply lengthen the sawtooth period by whatever time the for loop took.  That is not the case.   With the delay loop uncommented, the saw tooth pattern goes away completely and the P3.0 pin stays flat level at 3.2V.  No steps up or down, high all the time at 3.2V...

I can't figure out what could cause this behavior.   Any thoughts appreciated.

Also - The P3 GPIO output pins work just fine when I toggle them from other programs.  I generate 0 - 3.2V square waves from other timer based ISRs in other programs so it is not a hardware anomaly. 

- Dave


#include <msp430.h>

int main(void)
{
volatile unsigned int i;
volatile unsigned int j;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC12CTL0 = SHT0_2 + ADC12ON; // Set sampling time, turn on ADC12
ADC12CTL1 = SHP; // Use sampling timer
ADC12IE = 0x01; // Enable interrupt
ADC12CTL0 |= ENC; // Conversion enabled
P6SEL |= 0x01; // P6.0 ADC option select
P1DIR |= 0x01; // P1.0 output
P3DIR |= 0x03; // P3.0 & P3.1 output

P3OUT &= ~0x03; // both debug pins low
for (;;)
{

// for ( i=0; i<0x36000; i++) // Delay for settling
// {
// j = i;
// }


P3OUT |= 0x01;// debug pin high
ADC12CTL0 |= ADC12SC; // Sampling open
__bis_SR_register(CPUOFF + GIE); // LPM0, ADC12_ISR will force exit
}
}

// ADC12 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC12_VECTOR
__interrupt void ADC12_ISR (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12_ISR (void)
#else
#error Compiler not supported!
#endif
{
P3OUT &= ~0x01; // debug pin low in ISR

if (ADC12MEM0 < 0x7FF)
P3OUT &= ~0x02; // Clear P3.1 LED off
else
P3OUT |= 0x02; // Set P3.1 LED on
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}

  • dpekin said:
    When I compile and run the sample, I see about a 70us sawtooth pattern on the scope.  The pattern is strange in that it steps up from 3.2v to 3.8v.   Then there's a slow decay  (about 30us) from 3.8 back down to 3.2.  It stays at 3.2 for another 40us and then it steps back up to 3.8 to complete the cycle.  It is very repeatable. 

    What's happening on VCC pin at the same time?

  • VCC is stable 3.3V

  • So you say that just because you start ADC, chip which is powered by 3.3V miraculously outputs 3.8V? - Wow.

    Sawtooth is "slow" to be overshoot either. I have no clue how it can even happen unless you are missing something else like unlikely wrong scope ground connection :)

  • Wait.. you said "With the delay loop uncommented, the saw tooth pattern goes away completely and the P3.0 pin stays flat level at 3.2V.". This possibly does not let CPU sleep in LPM0 anymore, thus consumption pattern is changed. Are you sure nothing happens to VCC while pin output jump above 3.3V? Is there any other higher than 3.3V voltage source in your circuit, supposedly connected to msp430 somehow? Maybe it is voltage you measure with ADC which is above 3.3V? Any chance to show schematics of your board?

  • Can't post the schematic. Yes, we have aux power to the board but the real issue is that adding a NOP delay loop changes the behavior totally.
    I think there's a problem with the sample ADC example code which this is but a small derivative from...
  • dpekin said:
    I think there's a problem with the sample ADC example code

    You think that problematic ADC sample code can somehow generate higher than VCC, output voltages on the pin? :) Think twice.

  • You are correct that it is my mistake on voltages.  After reviewing the circuit, I see the point at which I was sampling the voltage is after a current driver.  The test point is switched by a transistor driven by the GPIO.  My mistake.  That probably explains the strange waveform I was seeing as well....  I'll need to see if I can probe the GPIO pin directly.  I would sure like something to make sense w/ this board.  

**Attention** This is a public forum