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.

MSP430FR5969: UART communication with zigbee works only when microcontroller is powered by USB

Part Number: MSP430FR5969

Hello,

I am new to this forum and a beginner in the msp430 architecture. I want to send data (internal temperature sensor data which is to be transmitted only once at start up) to remote zigbee using msp430 by UART protocol. I was successful in doing that using the launchpad by connecting the zigbee to the 2.0 and 2.1 UART pins for communication. But when I tried to do the same with external power supply (3.3V terminal to VCC and -ve terminal to GND) it doesn't work. It only seemed to work when I was powering up the microcontroller using USB from a PC. Am i doing something wrong or can it be that I am required to use pin 2.5 and 2.6 (eUCSIA1) when giving external power supply. I am attaching the code below: 

#include <msp430.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

char temp_int_char[5];
char temp_rm_char[5];
char mv_char[5];
char charmemval[] = "ADC12MEM0 Value: ";
char temperature[] = "The Temperature in degree is: ";
char newline[] = " \r\n";
char dot[] = ".";

#define CALADC12_12V_30C  *((unsigned int *)0x1A1A)   // Temperature Sensor Calibration-30 C
                                                      //See device datasheet for TLV table memory mapping
#define CALADC12_12V_85C  *((unsigned int *)0x1A1C)   // Temperature Sensor Calibration-85 C

unsigned int temp;
volatile float temperatureDegC;
volatile float temperatureDegF;

void ser_output(char *str);


int main(void)
{
    volatile float voltage;
    int i;
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  CSCTL0_H = CSKEY_H;
  CSCTL2 |= SELA__VLOCLK; //Select ACLK to use VLO which runs at about 10KhZ
  CSCTL0_H = 0;

  P1DIR |= BIT0;      //set pin 1.0 as output
  P1OUT &= ~BIT0;         // set pin 1.0 as low

 // P1DIR |= BIT3;      //set pin 1.3 as output
 //     P1OUT |= BIT3;      //set pin 1.3 as high

 //     P1DIR |= BIT2;      //set pin 1.2 as output
 //     P1OUT |= BIT2;      //set pin 1.2 as high

 //     P1DIR |= BIT4;      //set pin 1.4 as output
 //     P1OUT &= ~BIT4;     //set pin 1.4 as low

//  P4DIR |= BIT6;      //set pin 4.6 as output
//  P4OUT |= BIT6;      //set pin 4.6 as high
  initialize_UART();


  // Initialize the shared reference module
  // By default, REFMSTR=1 => REFCTL is used to configure the internal reference
  while(REFCTL0 & REFGENBUSY);              // If ref generator busy, WAIT
  REFCTL0 |= REFVSEL_0 + REFON;             // Enable internal 1.2V reference

  /* Initialize ADC12_A */
  ADC12CTL0 &= ~ADC12ENC;                   // Disable ADC12
  ADC12CTL0 = ADC12SHT0_8 + ADC12ON;        // Set sample time
  ADC12CTL1 = ADC12SHP;                     // Enable sample timer
  ADC12CTL3 = ADC12TCMAP;                   // Enable internal temperature sensor
  ADC12MCTL0 = ADC12VRSEL_1 + ADC12INCH_30; // ADC input ch A30 => temp sense
  ADC12IER0 = ADC12IE0;                         // ADC_IFG upon conv result-ADCMEMO

  while(!(REFCTL0 & REFGENRDY));            // Wait for reference generator
                                            // to settle
  ADC12CTL0 |= ADC12ENC;
  ADC12CTL0 |= ADC12SC;                   // Sampling and conversion start
  __bis_SR_register(LPM0_bits | GIE);     // LPM0 with interrupts enabled
 // __no_operation();
  //while(ADC12CTL1 & ADC12BUSY);
  int memval = ADC12MEM0;
     // Temperature in Celsius. See the Device Descriptor Table section in the
     // System Resets, Interrupts, and Operating Modes, System Control Module
     // chapter in the device user's guide for background information on the
     // used formula.
     temperatureDegC = (float)(((long)temp - CALADC12_12V_30C) * (85 - 30)) /
             (CALADC12_12V_85C - CALADC12_12V_30C) + 30.0f;

     //print temp value to UART terminal
     int temp_int = floor(temperatureDegC);
     int temp_rmndr = floor((temperatureDegC - temp_int) * 1000);
     ltoa(memval, mv_char, 10);
     ltoa(temp_int,temp_int_char, 10);
     ltoa(temp_rmndr,temp_rm_char, 10);
     ser_output(charmemval); ser_output(mv_char); ser_output(newline);
     ser_output(temperature); ser_output(temp_int_char); ser_output(dot); ser_output(temp_rm_char); ser_output(newline);
//     P1OUT &= ~BIT2;        // stop driving pmos source
 //    P1OUT |= BIT4;         //PMOS gate high to disconnect from the circuit
     P1OUT |= BIT0;         // set pin 1.0 as high indicating completion of zigbee communication
 while(1)
  {


    __no_operation();


    //for(i=0; i<30000;i++){}
    // Temperature in Fahrenheit Tf = (9/5)*Tc + 32
    //temperatureDegF = temperatureDegC * 9.0f / 5.0f + 32.0f;

   // __no_operation();                       // SET BREAKPOINT HERE
  }
}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void)
#else
#error Compiler not supported!
#endif
{
  switch(__even_in_range(ADC12IV, ADC12IV_ADC12RDYIFG))
  {
    case ADC12IV_NONE:        break;        // Vector  0:  No interrupt
    case ADC12IV_ADC12OVIFG:  break;        // Vector  2:  ADC12MEMx Overflow
    case ADC12IV_ADC12TOVIFG: break;        // Vector  4:  Conversion time overflow
    case ADC12IV_ADC12HIIFG:  break;        // Vector  6:  ADC12BHI
    case ADC12IV_ADC12LOIFG:  break;        // Vector  8:  ADC12BLO
    case ADC12IV_ADC12INIFG:  break;        // Vector 10:  ADC12BIN
    case ADC12IV_ADC12IFG0:                 // Vector 12:  ADC12MEM0 Interrupt
      temp = ADC12MEM0;                     // Move results, IFG is cleared
      __bic_SR_register_on_exit(LPM0_bits); // Exit active CPU
      break;
    case ADC12IV_ADC12IFG1:   break;        // Vector 14:  ADC12MEM1
    case ADC12IV_ADC12IFG2:   break;        // Vector 16:  ADC12MEM2
    case ADC12IV_ADC12IFG3:   break;        // Vector 18:  ADC12MEM3
    case ADC12IV_ADC12IFG4:   break;        // Vector 20:  ADC12MEM4
    case ADC12IV_ADC12IFG5:   break;        // Vector 22:  ADC12MEM5
    case ADC12IV_ADC12IFG6:   break;        // Vector 24:  ADC12MEM6
    case ADC12IV_ADC12IFG7:   break;        // Vector 26:  ADC12MEM7
    case ADC12IV_ADC12IFG8:   break;        // Vector 28:  ADC12MEM8
    case ADC12IV_ADC12IFG9:   break;        // Vector 30:  ADC12MEM9
    case ADC12IV_ADC12IFG10:  break;        // Vector 32:  ADC12MEM10
    case ADC12IV_ADC12IFG11:  break;        // Vector 34:  ADC12MEM11
    case ADC12IV_ADC12IFG12:  break;        // Vector 36:  ADC12MEM12
    case ADC12IV_ADC12IFG13:  break;        // Vector 38:  ADC12MEM13
    case ADC12IV_ADC12IFG14:  break;        // Vector 40:  ADC12MEM14
    case ADC12IV_ADC12IFG15:  break;        // Vector 42:  ADC12MEM15
    case ADC12IV_ADC12IFG16:  break;        // Vector 44:  ADC12MEM16
    case ADC12IV_ADC12IFG17:  break;        // Vector 46:  ADC12MEM17
    case ADC12IV_ADC12IFG18:  break;        // Vector 48:  ADC12MEM18
    case ADC12IV_ADC12IFG19:  break;        // Vector 50:  ADC12MEM19
    case ADC12IV_ADC12IFG20:  break;        // Vector 52:  ADC12MEM20
    case ADC12IV_ADC12IFG21:  break;        // Vector 54:  ADC12MEM21
    case ADC12IV_ADC12IFG22:  break;        // Vector 56:  ADC12MEM22
    case ADC12IV_ADC12IFG23:  break;        // Vector 58:  ADC12MEM23
    case ADC12IV_ADC12IFG24:  break;        // Vector 60:  ADC12MEM24
    case ADC12IV_ADC12IFG25:  break;        // Vector 62:  ADC12MEM25
    case ADC12IV_ADC12IFG26:  break;        // Vector 64:  ADC12MEM26
    case ADC12IV_ADC12IFG27:  break;        // Vector 66:  ADC12MEM27
    case ADC12IV_ADC12IFG28:  break;        // Vector 68:  ADC12MEM28
    case ADC12IV_ADC12IFG29:  break;        // Vector 70:  ADC12MEM29
    case ADC12IV_ADC12IFG30:  break;        // Vector 72:  ADC12MEM30
    case ADC12IV_ADC12IFG31:  break;        // Vector 74:  ADC12MEM31
    case ADC12IV_ADC12RDYIFG: break;        // Vector 76:  ADC12RDY
    default: break;
  }
}

void ser_output(char *str){
    while(*str != 0){
        while (!(UCA0IFG&UCTXIFG));
        UCA0TXBUF = *str++;
    }
}

void initialize_UART(void)
{
    // Configure GPIO
     P2SEL1 |= BIT0 | BIT1;                    // USCI_A0 UART operation
     P2SEL0 &= ~(BIT0 | BIT1);
     //P4DIR |= BIT6;
     //P4OUT &= ~BIT6;

     // Disable the GPIO power-on default high-impedance mode to activate
     // previously configured port settings
     PM5CTL0 &= ~LOCKLPM5;

     // Startup clock system with max DCO setting ~8MHz
     CSCTL0_H = CSKEY >> 8;                    // Unlock clock registers
     CSCTL1 = DCOFSEL_3 | DCORSEL;             // Set DCO to 8MHz
     CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
     CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers
     CSCTL0_H = 0;                             // Lock CS registers

     // Configure USCI_A0 for UART mode
     UCA0CTLW0 = UCSWRST;                      // Put eUSCI in reset
     UCA0CTLW0 |= UCSSEL__SMCLK;               // CLK = SMCLK
     // Baud Rate calculation
     // 8000000/(16*9600) = 52.083
     // Fractional portion = 0.083
     // User's Guide Table 21-4: UCBRSx = 0x04
     // UCBRFx = int ( (52.083-52)*16) = 1
     UCA0BR0 = 52;                             // 8000000/16/9600
     UCA0BR1 = 0x00;
     UCA0MCTLW |= UCOS16 | UCBRF_1;
     UCA0CTLW0 &= ~UCSWRST;
    // UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
}

Thanks in advance.

**Attention** This is a public forum