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.

MSP430FR2311: Set Onboard OA as Inverting OA w/ Gain

Part Number: MSP430FR2311
Other Parts Discussed in Thread: MSP430WARE,

Hi

I'm using MSP430Ware's Driver Library in order to program the onboard OA to act as a inverting OA.

My question is how do you sent the gain? Even TI's "How to Use the Integrated Operational Amplifiers on MSP430FR2311"  Document () doesn't mention it.

Secondly, in the MSP430FR user guide, it says that in order to set the OA as inverting, you have to set the PGA MSEL as source (MSEL = 00). How do you do this? PGA MSEL isn't mentioned in the MSP4302311.h or Driver Library, so I have no idea how to do this.

I'd really appreciate help, or at least a point in the right direction.

Thank you in advance!

  • Hi Diana,

    First, thank you for your detailed post.

    Regarding your question, you're referencing the correct figure in the User's Guide for an inverting op-amp mode/configuration. In Table 19-2, you can see the different modes and PGA gain settings. The columns "MSEL", "PSEL", "NSEL", and "GAIN" are all register fields (sections or groups of bits in certain control registers) that would be configured for your requirements.

    For example, you need to operate in Inverting PGA mode. Thus, MSEL would equal 00b. As you can see in Figure 19-8 and Table 19-7, the MSEL field is defined by Bits 1 to 0 in the SAC PGA Control Register, SACxPGA. The complete list of SAC registers can be found in Table 19-5.

    Now, the Driver Library allows users to configure modules like the SAC at a much higher, abstracted level (using an API) than what I've described above, which is the register level. After looking in the MSP430 DriverLib for MSP430FR2xx_4xx Devices User's Guide (v2.80.00.01), I didn't find many functions for the SAC module. Like you, I wasn't able to find any references to SACxPGA or SACxSMEL after searching in the 'sac.c' and 'sac.h' files found under the project folder -> driverlib -> MSP430FR2xx_4xx in CCS. Perhaps, additional functions for the SAC will be added in the future.

    In the meantime, I'd recommend taking a look at our register-level code examples as a foundation for getting started. Then, you can add your changes to the SACxPGA register to this example moving forward.

    msp430fr231x_SAC_L1_03.c

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2015, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //  MSP430FR231x Demo - TRI0+SAC0, Two-Stage amplifier,
    //                      Use ADC to sample SAC0 ouput
    //
    //  Description: Configure SAC0 and TRI0 as two-stage amplifier.
    //  As the code example practice, TRI0- and TRI0O are connected directly. 
    //  And OA0- and OA0O are connected as below to implement x3 amplifier. 
    //  The input signal which is in the range 0~1/2Vcc is input through TRI0+,
    //  TRI0 output is connected to SAC0 positive input terminal internally.
    //  Use ADC CH A3 to sample SACO output. If higher than 1/2 VCC, turn on LED.
    //  Both SAC0 and TRI0 are configured to low speed and low power mode.
    //  Need to add external circuit to silicon, make sure SAC0 and TRI0
    //  work in amplifier mode.
    //  ACLK = n/a, MCLK = SMCLK = default DCODIV ~1MHz.
    //  Note: Please select SBW interface instead of JTAG interface while debugging 
    //        the TRI because the TRI pins are alternatively used with JTAG pins.
    //
    //                MSP430FR231x
    //             -------------------
    //         /|\|          P1.2/OA0-|----||---------R2=100Kohm---GND
    //          | |                   |  R1=200Kohm
    //          | |          P1.3/OA0O|----||              
    //          --|RST       P1.4/OA0+|
    //            |         P1.5/TRI0O|----||
    //            |         P1.6/TRI0-|----||
    //            |         P1.7/TRI0+|<------0~1/2*Vcc
    //            |                   |
    //            |               P1.0|----> LED
    //
    //   Darren Lu
    //   Texas Instruments Inc.
    //   July 2015
    //   Built with IAR Embedded Workbench v6.30 & Code Composer Studio v6.1
    //******************************************************************************
    #include <msp430.h>
    
    unsigned int adcResult;
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
    
      P1DIR |= BIT0;                            // Select P1.0 as output
      P1OUT &= ~BIT0;                           // Set P1.0 output low
      PM5CTL0 &= ~LOCKLPM5;                     // Disable the GPIO power-on default high-impedance mode
                                                // to activate previously configured port settings
    
      //Select P1.2 P1.3 P1.4 as SAC function
      //Select P1.5 P1.6 P1.7 as TRI fucntion
      P1SEL0 |= BIT2 + BIT3 + BIT4 + BIT5 + BIT6 + BIT7;
      P1SEL1 |= BIT2 + BIT3 + BIT4 + BIT5 + BIT6 + BIT7;
    
      TRI0CTL = TRIPM + TRIEN;                  // Enable TRI, Select low speed and low power mode
    
      SAC0OA |= PSEL1;                          // Select TRI output as SAC positive input source
      SAC0OA |= NMUXEN + PMUXEN;                // Enable negative and positive input
      SAC0OA |= OAPM;                           // Select low speed and low power mode
      SAC0OA |= SACEN + OAEN;                   // Enable SAC and OA
    
      // Configure ADC10
      ADCCTL0 &= ~ADCENC;                       // Disable ADC
      ADCCTL0 = ADCSHT_2 | ADCON;               // ADCON, S&H=16 ADC clks
      ADCCTL1 = ADCSHP;                         // ADCCLK = MODOSC; sampling timer
      ADCCTL2 = ADCRES;                         // 10-bit conversion results
      ADCIE = ADCIE0;                           // Enable ADC conv complete interrupt
      ADCMCTL0 = ADCINCH_3 | ADCSREF_0;         // A3 ADC input select = OA output
                                                // Vref = DVCC
    
      while(1)
      {
          ADCCTL0 |= ADCENC | ADCSC;          // Sampling and conversion start
          __bis_SR_register(LPM0_bits | GIE); // Enter LPM0, ADC_ISR will force exit
          __no_operation();                   // For debug only
    
          if (adcResult > 512)                // OA output > 1/2 VCC
              P1OUT |= BIT0;                  // Set P1.0 LED on
          else
              P1OUT &= ~BIT0;                 // Clear P1.0 LED off
      }
    }
    
    // ADC interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=ADC_VECTOR
    __interrupt void ADC_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(ADC_VECTOR))) ADC_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      switch(__even_in_range(ADCIV, ADCIV_ADCIFG))
      {
          case ADCIV_NONE:
              break;
          case ADCIV_ADCOVIFG:
              break;
          case ADCIV_ADCTOVIFG:
              break;
          case ADCIV_ADCHIIFG:
              break;
          case ADCIV_ADCLOIFG:
              break;
          case ADCIV_ADCINIFG:
              break;
          case ADCIV_ADCIFG:
              adcResult = ADCMEM0;            // Read ADC memory
              __bic_SR_register_on_exit(LPM0_bits);// Exit from LPM
              break;
          default:
              break;
      }
    }

    Regards,

    James

    MSP Customer Applications

  • Hi James. Thanks for the quick reply! I quickly realized that Driver Library was probably a no go for setting MSEL and the gain. The next issue I've been having is that I cannot find the SACxPGA register in the MSP430FR2311.h file, which isn't a part of Driver Library. I've been able to understand the example you shared pretty well, but as far as I can see, the registers used there are all defined in MSP430FR2311.h. I'm sure the SACxPGA register is easily accessible, however I haven't been able to find its declaration in the header file so I have no idea how to call it.
  • Hi Diana,

    I've figured out the issue here, and I'm sorry for not catching it sooner. Basically, the MSP430FR2311 only supports a SAC-L1 configuration, which is the minimum SAC feature set. Thus, its function is limited to OA only, not PGA or DAC. I found this mentioned on the first page of the datasheet and also in Section 6.11.13.

    This is the reason that only the SACxOA register is shown in the MSP430FR2311.h file and that there are a limited number of API functions in DriverLib for this device. Table 19-4 in the User's Guide describes all of the possible SAC configuration feature sets.

    Hopefully this clears everything up.

    Regards,

    James

    MSP Customer Applications

**Attention** This is a public forum