[FAQ] TMS320F2800137: How do I port E-Metrology library from F28P55 to another TI C28x MCU Device?

Part Number: TMS320F2800137
Other Parts Discussed in Thread: C2000WARE

Hello,

I want to port the E-Metrology library fom F28P55 to F2800137. I want to enable only single-phase calculations and I do not wish to calculate THD. What steps can I follow to do this?

  • Hello,

    Please follow these steps to port the E-Metrology Library from F28P55 to F2800137.

    1. Download the E-Metrology library for F28P55 from here.

    2. Firstly, in order to enable single-phase calculations and disable THD calculations, you will have to make changes to the template.h file included in the library. Please consult User Guide for E-Metrology Library for Digital Power Applications with F28P55x and F28P65x for help with the same.

    3. Once you have made the above changes, build the project in CCS. Check the .map file to make sure that the RAM and Flash usage are less than the RAM and Flash size available in F2800137 device. 

    4. Once you have confirmed that the project will indeed fit in F2800137, then we are ready to port the project.

    5. Import an empty driverlib F2800137 project from C2000Ware into your CCS Workspace and rename it. For example - energy_metrology_f2800137.

    6. Delete the default main.c file and change the build configuration to CPU1_FLASH. 

    7. Copy the following files from energy_metrology_f28p55 project into your F2800137 project.

    Source Files

    • metrology_main_file.c - Main application logic
    • metrology_background.c - ISR per-sample processing
    • metrology_calculations.c - Power/energy calculations
    • metrology_foreground.c - Foreground processing wrapper
    • metrology_setup.c - Initialization functions
    • metrology_fir_table.c - Phase correction FIR coefficients 
    • fft.c - FFT for harmonic analysis (exclude from build if you do not want to do THD calculations)

    Header Files

    • metrology.h - Main declarations
    • metrology_structs.h - Data structures
    • metrology_defines.h - Constants and enums
    • metrology_calibration.h - Calibration data structures
    • metrology_setup.h - Init function declarations
    • metrology_background.h - ISR function declarations
    • metrology_foreground.h - Foreground function declarations
    • template.h - Configuration and calibration constants
    • hw_types.h - Contains type specifications

    Libraries

    • Link the c2000ware\libraries\math\FPUfastRTS\c28\lib\rts2800_fpu32_fast_supplement.lib library to your project 

    8. Update driverlib path and Sys Config file. 

    • Change the driverlib include path from f28p55 to f2800137. The peripheral initialization can be found in metrology_main_file.c.
    • Update c2000.syscfg from the f2800137 project to include timer peripherals. In order to do this, open energy_metrology_f28p55\device\lab_f28p55x_launchpad.syscfg from the downloaded E-Metrology project (from step 1). Now add all the peripherals and their settings from lab_f28p55x_launchpad.syscfg to c2000.syscfg which will be present by default in your empty f2800137 project. Make sure your .syscfg file is identical.

    9. Modify the default Flash Linker file from the f2800137 project 280013x_generic_flash_lnk.cmd for the E-Metrology library. 

    10. Comment out the #include<fft.h> from all the files (since we are not using FFT functionality to do THD calculation) to make sure you do not get include errors. 

    Please note the following memory considerations when trying to port the E-Metrology Library for any C28x device

    1. E-Metrology with 3-phase support and THD calculation enabled will take 15.8 KB Flash and 40.6 KB RAM.

    2. E-Metrology with 1-phase support and THD calculation disabled will take 11.4 KB Flash and 2.1 KB RAM.

    3. Disabling phase correction will further lead to a few bytes of memory reduction.

    Please find the E-Metrology library migrated for F2800137 here -  energy_metrology_f2800137.zip


    Thanks and Regards,

    Ira