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.

CCS/TIDA-00120: MSP430F5132

Part Number: TIDA-00120
Other Parts Discussed in Thread: MSP430F5132

Tool/software: Code Composer Studio

Sir,

     I am working on TIDA-00120 referance design. In this design programming, two ADCs A7 and A8 are not used. I want to enable it to my application. I was try but its not working. Please help me to enable the ADC 7 and 8. 

  • Hello Sanjay,

    Although I'm unfamiliar with this TI Design, I would recommend that you refer to our code examples for MSP430F5132 inside the TI Resource Explorer in CCS. Combined with referencing the MSP430x5xx and MSP430x6xx Family User's Guide, you can add to or re-configure the TI Design source code to add support for the ADC A7 and A8 channels.

    Looking at the 'main.c' file from the PMP7605 source code, I found the "Init_ADC()" function where the ADC setup is done. Assuming you want the additional A7 and A8 channels to be similar to the other channels, one of the first things that I would change is "ADC10INCH_5" to "ADC10INCH_8".

    void Init_ADC (void)
    {
    	  // Configure ADC10
    	  ADC10CTL0 = ADC10SHT_2 + ADC10MSC + ADC10ON;// 16ADCclks, MSC, ADC ON
    	  ADC10CTL1 = ADC10SHP + ADC10CONSEQ_1;     // sampling timer, s/w trig.,single sequence
    	  ADC10CTL2 |= ADC10RES;                    // 10-bit conversion results
    	  ADC10MCTL0 = ADC10INCH_5 + ADC10SREF_1;   // A0,A1,A2,A3,A4,A5(EoS), Vref
    	  // By default, REFMSTR=1 => REFCTL is used to configure the internal reference
    	  while(REFCTL0 & REFGENBUSY);              // If ref generator busy, WAIT
    	  REFCTL0 |= REFVSEL_2+REFON;               // Select internal ref = 2.5V
    	  _delay_cycles (1000);
    	  // Configure DMA0 (ADC10IFG trigger)
    	  DMACTL0 = DMA0TSEL_24;                    // ADC10IFG trigger
    	  __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &ADC10MEM0);
    	                                            // Source single address
    	  __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &ADC_Readings[0]);
    	                                            // Destination array address
    	  DMA0SZ = 0x06;                            // 3 conversions
    	  DMA0CTL = DMADT_4 + DMADSTINCR_3 + DMAEN + DMAIE;
    
    }

    Regards,

    James

    MSP Customer Applications

  • Sir,
    I have already done this process but i can't get ADC values.
  • Hello,

    That's good to know, but please provide more details about what you've tried. First, I would recommend you break up this challenge. Start with our code examples and fully understanding how to read the ADC data from the desired channels without using the DMA. Then, figure out how the DMA is being used in the TI Design code (since it's initialized in the "Init_ADC" function) to move the ADC data from the buffers to arrays, and then integrate everything in the TI Design code piece by piece.

    Regards,

    James

    MSP Customer Applications
  • sir,
    I have done bellow changes in this program to enable the ADC A7. I have increase the array value of ADC (1). Then define the integers. for store the values of ADC output (2). Define the 7th ADC name (3). Initialize the integers from 0 value(4). Take the average of ADC values and store the final value of average ADC in another integer(5). After use this value again initialize the integer from 0 (6). Changes in average Value of ADC function, change in IO function and changes in ADC initialize function (7). But i can't enable the A7 and can't get the value on A7.

    1. unsigned int ADC_Readings [7];

    2. unsigned int Temp_Comp, Temp_Comp_Avg=0;

    3. #define T_C 7

    4. Temp_Comp_Avg = 0;

    5. Temp_Comp = Temp_Comp_Avg / ctr_th;

    6. Temp_Comp_Avg = 0;

    7. #pragma vector=DMA_VECTOR
    __interrupt void DMA0_ISR (void)
    {
    switch(__even_in_range(DMAIV,16))
    {
    case 0: break; // No interrupt
    case 2:
    // sequence of conversions complete
    ADC10CTL0 &= ~ADC10ENC;
    Panel_Voltage_Avg += ADC_Readings [P_V];
    Battery_Voltage_Avg += ADC_Readings [B_V];
    Panel_Current_Avg += ADC_Readings [P_I_S];
    Battery_Current_Avg += ADC_Readings [B_I_S];
    Load_Current_Avg += ADC_Readings [B_I];
    Temp_Comp_Avg += ADC_Readings [T_C];
    Reading_Captured = 1;
    Avg_ctr ++;

    break; // DMA0IFG
    case 4: break; // DMA1IFG
    case 6: break; // DMA2IFG
    case 8: break; // Reserved
    case 10: break; // Reserved
    case 12: break; // Reserved
    case 14: break; // Reserved
    case 16: break; // Reserved
    default: break;
    }
    }


    /*Here all the PORT initialization is done*/
    void Init_IOs (void)
    {
    // Hi-Res freq locked; now configure ports to output PWMs at TD0/TD1
    P1SEL |= BIT7; // P1.7,TD0.1, options select
    P1DIR |= BIT7; // Output direction
    P2SEL |= BIT0 + BIT2 + BIT3; // P2.0/TD0.2, P2.2/TD1.1, P2.3/TD1.2, options select
    P2DIR |= BIT0 + BIT2 + BIT3 + BIT4 + BIT5 + BIT6; // Output direction
    // P3DIR &= ~BIT6;
    P2DIR &= ~BIT1;

    PMAPPWD = 0x02D52; // Enable Write-access to modify port mapping registers
    PMAPCTL = PMAPRECFG; // Allow reconfiguration during runtime
    P1MAP0|= PM_ANALOG; // Modify all PxMAPy registers
    P1MAP1|= PM_ANALOG; // Modify all PxMAPy registers
    P1MAP2|= PM_ANALOG; // Modify all PxMAPy registers
    P1MAP3|= PM_ANALOG; // Modify all PxMAPy registers
    P1MAP4|= PM_ANALOG; // Modify all PxMAPy registers
    P1MAP5|= PM_ANALOG; // Modify all PxMAPy registers
    P3MAP6|= PM_ANALOG; // Modify all PxMAPy registers
    PMAPPWD = 0; // Disable Write-Access to modify port mapping registers by writing incorrect key
    P1SEL |= BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5; // setting the port mapping register PxMAPy to PM_ANALOG together with PxSEL.y=1 when applying analog signals

    P3SEL |= BIT6;

    P3DIR |= BIT2 + BIT3;
    PANEL_DISABLE;
    }



    void Init_ADC (void)
    {
    // Configure ADC10
    ADC10CTL0 = ADC10SHT_2 + ADC10MSC + ADC10ON;// 16ADCclks, MSC, ADC ON
    ADC10CTL1 = ADC10SHP + ADC10CONSEQ_1; // sampling timer, s/w trig.,single sequence
    ADC10CTL2 |= ADC10RES; // 10-bit conversion results
    ADC10MCTL0 = ADC10INCH_7 + ADC10SREF_1; // A0,A1,A2,A3,A4,A5,A6,A7(EoS), Vref
    // By default, REFMSTR=1 => REFCTL is used to configure the internal reference
    while(REFCTL0 & REFGENBUSY); // If ref generator busy, WAIT
    REFCTL0 |= REFVSEL_2+REFON; // Select internal ref = 2.5V
    _delay_cycles (1000);
    // Configure DMA0 (ADC10IFG trigger)
    DMACTL0 = DMA0TSEL_24; // ADC10IFG trigger
    __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &ADC10MEM0);
    // Source single address
    __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &ADC_Readings[0]);
    // Destination array address
    DMA0SZ = 0x06; // 3 conversions
    DMA0CTL = DMADT_4 + DMADSTINCR_3 + DMAEN + DMAIE;

    }
  • Hello,

    For future reference, code is much more readable when posted to the forum using the Syntax Highlighter tool (looks like "</>") found under the "Insert Code, Attach Files and more..." link shown after you click the "Reply" button.

    As I mentioned before, remove the DMA code until you know you're reading the ADC data from all the channels. Right now, I think you're working with too many things at once and need to simplify before continuing.

    Regards,

    James

    MSP Customer Applications