SLUUDN8 July   2026 TMS320F28P550SJ , TMS320F28P650DK

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction
  5. 2Library Notice
  6. 3Library Architecture
    1. 3.1 Background Processing
    2. 3.2 Foreground Processing
    3. 3.3 Data Transfer Mechanism
  7. 4Metrology Calculations
  8. 5Configuration and Data Structures
  9. 6Calibration Module
  10. 7User Specific Configurations
    1. 7.1 Debug Mode
      1. 7.1.1 The Function of Debug Mode
      2. 7.1.2 How to Configure DEBUG Mode Parameters
    2. 7.2 ADC Mode
      1. 7.2.1 Using the On-Chip ADC
      2. 7.2.2 Two Point Calibration
        1. 7.2.2.1 Step 1 – Offset Calibration (Zero-Input Point)
        2. 7.2.2.2 Step 2 – Gain Calibration (Full-Scale Point)
      3. 7.2.3 Using an External ADC
    3. 7.3 Switching Between Modes
    4. 7.4 THD Algorithm Selection
      1. 7.4.1 Method 1 – Based on PLL (Default When the HARMONICS_SUPPORT Macro is Not Defined)
      2. 7.4.2 Method 2 – Goertzel DFT (When the HARMONICS_SUPPORT and USE_GOERTZEL_THD Macros are Both Defined)
      3. 7.4.3 Method 3 – 2048-Point Real FFT (When the HARMONICS_SUPPORT Macro is Defined But the USE_GOERTZEL_THD Macro is Not)
    5. 7.5 Topology Selection
    6. 7.6 Enable Features
    7. 7.7 System Parameters
    8. 7.8 Scaling Factors Per Phase
  11. 8Running the Example
    1. 8.1 Accessing the Parameters Per Phase
    2. 8.2 Accessing the Total System Measurements
    3. 8.3 Accessing the Phase Status Flags

Using an External ADC

If the on-chip ADC is replaced with an external ADC (for example a sigma-delta device connected over SPI), the following changes are required:

  1. In the adc_config.c file – Replace the ADC_readNormalized() function calls inside the ADC_readMetrologyData() function with calls to the external ADC driver. The function must write a normalized float (centered at zero, full scale approximately ±1.0) into workingData→rawVoltageData[PHASE_x] and workingData→rawCurrentData[PHASE_x]. The normalization convention is:

    normalized = (raw_sample - dc_offset) / gain

    Where dc_offset and gain are the same two-point calibration constants described above, applied to the raw output counts of the external ADC.

  2. In the adc_config.h file – Remove or replace the ADC_VA_RESULT | ADC_VA_SOC macro definitions since the names generated in the SysConfig menu no longer apply. Define whatever constants the driver requires instead. ADC_VOLTAGE_DC_OFFSET, ADC_CURRENT_DC_OFFSET, ADC_VOLTAGE_GAIN, and ADC_CURRENT_GAIN remain valid and must be set to match the resolution and front-end gain of the external ADC.
  3. In the .syscfg file – Remove the ADCA and ADCB peripheral instances if the on-chip ADC is not used, to avoid consuming memory and clock resources.
  4. In the metrology_main_file.c file – If the external ADC uses a data-ready interrupt rather than a timer trigger, move the ADC_readMetrologyData() and Metrology_perSampleProcessing() function calls from the cpuTimer0ISR functions into the external ADC interrupt handler instead. Verify that the ISR executes at the same rate as SAMPLE_RATE.
  5. In the template.h file – The PHASE_x_VOLTAGE_SCALE_FACTOR and PHASE_x_CURRENT_SCALE_FACTOR macro must still reflect the physical scaling of the external ADC analog front-end, as the metrology engine uses these macros to convert normalized samples to volts and amps.