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.

Compiler/MSP430G2553: MSP430 ADC does not work in release mode

Part Number: MSP430G2553

Tool/software: TI C/C++ Compiler

Hi,

I have an MSP430G2553 device on a PCB which I program through the launchpad. I load a piece of code on the device that works fine as long as the PCB is connected to the launchpad. The code consists of a PWM and an ADC. As soon as I remove the connection to the launchpad and supply the PCB with 3.5V. the ADC stops working but the PWM still works. I know that the ADC stops working because I read from a pin and output something based on the reading, and the output signals show nothing in release mode. 

I have a second problem with getting the code to work in release mode. I am currently running the device at 1MHZ. If I run the device at 16MHz, it will again work fine when connected to the launch pad. The PWM works as before up to DCO frequency of 12MHZ in release mode, as well. But at 16MHZ, even the PWM stops working in release mode. 

Any advice or suggestions of why this is happening or what I can do so the code works in release mode?

Thanks a lot in advance.

Here is the code for your reference: 

#include "msp430G2553.h"
#include <stdint.h>

//void ConfigureADC()
void ConfigureADC(void)

{
    ADC10CTL1 |= INCH_5 ;       //read from P1.5, floating pin
    ADC10CTL0 |= SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE;
    ADC10AE0 |= BIT5;
}

volatile uint8_t A0;   			//store ADC bit here

//state name
static uint8_t S0 = 0;
static uint8_t S1 = 0;

void main( void )
{
  // Stop watchdog timer
	WDTCTL = (WDTPW | WDTHOLD);

  // Set range to 1MHz
  BCSCTL1 = CALBC1_1MHZ;
  // Set DCO step and modulation to 1MHz
  DCOCTL = CALDCO_1MHZ;
 // BCSCTL2 &= ~(DIVS_3);

  P1SEL    |= 0x40;                                   	// Set special function of P1.6 to timer module
  P1DIR    |= 0x5F;                                    	// Set to output direction
  P2DIR    |= 0X0F;
  P1OUT    |= 0x00;                           			// Set P1.0 ON, P1.1 OFF
  P2OUT    |= 0X00;

  // PWM frequency of 40kHz (25us)
  TA0CCR0 = 25;
  // Start with duty cycle base
  TA0CCR1 = 4;
  // Reset/set mode
  TA0CCTL1 = OUTMOD_7;
  // SMCLK, divider 1, up-mode
  TA0CTL = (TASSEL_2 | ID_0 | MC_1);


  ConfigureADC();

  __bis_SR_register( GIE );                // Enable global interrupts

  // Endless loop - main program
  while( 1 )

  {
		  ADC10CTL0 |= ENC + ADC10SC;   //Sampling and conversion start
	      __bis_SR_register(CPUOFF + GIE );

	      A0 = ADC10MEM & 0X1F;	// to get a 5-bit Random number

			if (!S0 && !S1 )
			{

				P1OUT = A0 ;	//randomly select pins (P1.0 to P1.4)
				P2OUT = 0X00;	

				__delay_cycles(3200);	//pulse duration
  				//Flag to go to next state
				S0 = 0;
				S1 = 1;
			}

  			if (!S0 && S1)
  			{

  				P1OUT = A0 ;	//randomly select pins (P1.0 to P1.4)
  				P2OUT = 0X0C;	

  				__delay_cycles(1000);	//pulse duration

  				S0 = 1;
  				S1 = 0;

  			}

  			if (S0 && !S1  )
  			{

  				P1OUT = A0 ;	//randomly select pins (P1.0 to P1.4)
  				P2OUT = 0X09;	

  				__delay_cycles(1000);	//pulse duration

  				S0 = 1;
  				S1 = 1;

  			}

  			if (S0 && S1 )
  			{

  				P1OUT = A0 ;	//randomly select pins (P1.0 to P1.4)
  				P2OUT = 0X00;	

  				__delay_cycles(3200);	//pulse duration
  				S0 = 0;
  				S1 = 0;
  			}



  }

}

// ADC Interrupt service routine
#pragma vector = ADC10_VECTOR
__interrupt void ADC10_ISR( void )
{
__bic_SR_register_on_exit(CPUOFF); //Return to active mode
}

  • Hi Sahar,

    I have a few tips that hopefully might help you to debug your issue:

    1. When initializing the DCO, you need to consider the BCL12 erratum from the errata doc www.ti.com/lit/pdf/slaz440 and implement the workaround. I suspect this could be related to your 16MHz issue. Please follow the sequence mentioned in the TLV Structure chapter of the 2xx user's guide www.ti.com/lit/pdf/slau144 of clearing DCOCTL, loading BCSCTL1, and then loading DCOCTL.

      DCOCTL = 0;                               // Select lowest DCOx and MODx settings
      BCSCTL1 = CALBC1_16MHZ;                   // Set range
      DCOCTL = CALDCO_16MHZ;                    // Set DCO step + modulation

    2. Use one of your totally unused pins (You'll have to consider about your writes in main to P1OUT and adjust accordingly) to add a pin toggle into the ADC10_ISR. That way you can tell if you are ever entering the ISR, and how frequently, in the failing case. This could provide a clue about the flow of code when you are having your issue.

    3. Is 3.5V actually seen at the MSP430 DVcc pin? Or does that voltage go through other circuitry that the MSP DVcc could be lower? I ask because the minimum allowed voltage for 16MHz is 3.3V.

    These questions should help to give a better picture of what is going on.

    Regards,

    Katie

  • Hi Sahar,

    Did the above advice help, or are you still encountering problems?

    Regards,
    Katie
  • Hi Katie,
    Thank you so much for your suggestions. My problem is sort of resolved now.
    So no, I do not have a circuit between the supply and the microcontroller. The ADC was not working when I supplied the PCB with 3.5V but I found out that it works if it is supplied with 3.4V and 3.2V. The ADC also does not work if the microcontroller is supplied with 3.1V and 3.3V. So I would assume the issue is with the supply but I do not know why it works at some specific voltages only.
    Regarding the issue with not being able to generate any signals if the CPU is running at 16MHz, the problem still remains. All the signals look fine at 16MHz, when the PCB is connected to the Jtag, but nothing works when the PCB is supplied with the power supply. I have tried to go from 2.5V to 4V in steps of 100mV to see if it would have an effect, but that did not help.
    I tried the suggestions from the user manual as you recommended, but have not been able to get that to work.
    For now, I am supplying the PCB with 3.4V and running the CPU at 12MHz and everything works.
  • Hi Sahar,

    Do you have the 47k pullup resistor to Vcc on the RST line? This is a required connection (see connection of unused pins section 2.5 of the user's guide www.ti.com/lit/pdf/slau144 ), and I could see that with JTAG connected the line would be driven high by JTAG so it could mask the issue, but if you were missing the pullup the line might not be high when you are supplying Vcc to the board externally instead.

    Additionally, I'd recommend checking if you have the recommended caps on DVcc and AVcc from the user's guide www.ti.com/lit/pdf/slau144 section 22.2.9 ADC10 Grounding and Noise Considerations and that DVcc and AVcc are connected together. The ADC is sourced from AVcc so if that is not connected on your board it could make sense why the ADC does not work but other functions do...

    Regards,

    Katie

  • Hi Sahar,

    Did this help? Were you able to resolve your issue?

    Regards,
    Katie

**Attention** This is a public forum