Files
microchip-application-pec93…/Examples/pga/pga_src_io

pga_src_io

This example is used to demo the PGA module which uses GPIO Pins as input/output

  • Select PGA0 or PGA1

    // at main.c
    /**
     *  Select the terget OPAMP module
     *  + unmark CONFIG_USE_OPAMP_0 => OPAMP0
     *  + mark CONFIG_USE_OPAMP_0   => OPAMP1
     */
    #define CONFIG_USE_OPAMP_0
    
  • Configure the amplifier gain

    // at main.c
    /**
     *  The amplify gain, @ref OPAMP_PGAGainTypeDef
     *  ps. OPAMP_PGAGain_1 ~ OPAMP_PGAGain_16
     */
    #define CONFIG_AMP_GAIN             OPAMP_PGAGain_1
    
  • Configure the reference mVoltage of ADC to convert the sampled value to mVoltage

    // at main.c
    /**
     *  The reference mVoltage of ADC on board
     */
    #define CONFIG_ADC_REF_mVOLTAGE         3300
    
  • Configure VinM to use internal ground

    // at main.c
    #define CONFIG_SET_OPAMP_VINM_GND       1
    

Log

Use serial port with baudrate 115200, 8bit, no parity check.

  • Use OPAmp0 and PA8 links to VDD/VSS

    Oct  1 2025 14:25:16
    Run PGA-0 (Programmable Gain Amplifier)
      The gain 1
      VinP= PA8
      VinM= GND
      Vout= ADC AIN0                            <--- Vout directly links to AIN0
    ADC samples the PGA Vout= 0x08E6 (1835 mV)
    ADC samples the PGA Vout= 0x080D (1660 mV)
    ADC samples the PGA Vout= 0x061F (1262 mV)
    ADC samples the PGA Vout= 0x0590 (1147 mV)
    ADC samples the PGA Vout= 0x0E02 (2889 mV)
    ADC samples the PGA Vout= 0x0FFB (3295 mV)  <--- link VinP to VDD
    ADC samples the PGA Vout= 0x0FFB (3295 mV)
    ADC samples the PGA Vout= 0x0FFB (3295 mV)
    ADC samples the PGA Vout= 0x0FFA (3295 mV)
    ADC samples the PGA Vout= 0x0BB2 (2412 mV)
    ADC samples the PGA Vout= 0x0003 (2 mV)     <--- link VinP to VSS
    ADC samples the PGA Vout= 0x0001 (0 mV)
    ADC samples the PGA Vout= 0x0002 (1 mV)
    ADC samples the PGA Vout= 0x0003 (2 mV)
    
  • Use OPAmp0 and PA8 links to VDD/VSS

    ADC samples AIN9 (PA7)

    There is an impedance between Vout and AIN9(PA7). As this result, the ADC sample value is difference with Vout = AIN0 case

    Oct  1 2025 14:30:09
    Run PGA-0 (Programmable Gain Amplifier)
      The gain 1
      VinP= PA8
      VinM= GND
      Vout= PA7                                 <--- Vout to PA7
    ADC samples the PGA Vout= 0x0110 (219 mV)
    ADC samples the PGA Vout= 0x0056 (69 mV)    <--- link VinP to VSS
    ADC samples the PGA Vout= 0x0058 (70 mV)
    ADC samples the PGA Vout= 0x0059 (71 mV)
    ADC samples the PGA Vout= 0x0062 (78 mV)
    ADC samples the PGA Vout= 0x002B (34 mV)
    ADC samples the PGA Vout= 0x0038 (45 mV)
    ADC samples the PGA Vout= 0x0057 (70 mV)
    ADC samples the PGA Vout= 0x0064 (80 mV)
    ADC samples the PGA Vout= 0x0029 (33 mV)
    ADC samples the PGA Vout= 0x0031 (39 mV)
    ADC samples the PGA Vout= 0x0590 (1147 mV)
    ADC samples the PGA Vout= 0x0ADB (2238 mV)
    ADC samples the PGA Vout= 0x0B38 (2313 mV)
    ADC samples the PGA Vout= 0x0ECA (3050 mV)
    ADC samples the PGA Vout= 0x0F2F (3131 mV)  <--- link VinP to VDD
    ADC samples the PGA Vout= 0x0F58 (3164 mV)
    ADC samples the PGA Vout= 0x0F68 (3177 mV)
    ADC samples the PGA Vout= 0x0F43 (3147 mV)
    ADC samples the PGA Vout= 0x0F35 (3136 mV)
    ...