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.

LAUNCHXL-F280039C: eCAP Duty Cycle Measurement Problem

Part Number: LAUNCHXL-F280039C
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE, TMS320F280037C

The setup has PWM1A externally connected to GPIO23 and also to an oscilloscope.  Sysconfig values are set as:  EPWM  Timebase -120  CMPA 30, 60, 90;  ECAP1:  Capture Stop - event2  Event1 - rising   Event 2 - falling  No Counter Reset      CCS 20.3.0 debug register values: ECCTL0 - 76h, ECCTL1 - 8344h, ECCTL2 - 92h

The PWM output looks as expected on the scope.  Regardless of the value of CMPA (30, 60, 90) the eCap result stays the same (Cap2 - Cap1 = 121).  As noted, scope results are correct and reflect the changes.  Other frequences and duty cycles have been tried with the (ecap2 - ecap1) always equaling a 50% duty cycle.  This was verified in runs using event3 and clock resetting.

The goal is to establish code to read duty cycle data accurately.  Note: this is not an interconnection issue as the (Cap2 - Cap1) value changes proportionally with frequency changes, which are confirmed by the scope.

     

  • Can you maybe share your code? eCAP configuration and how you measure the duty cycle?

  • Hi Gary,

    Have you tried our eCAP examples in our C2000WARE SDK?

    This will have the recommended eCAP initalization for either operating the eCAP in one shot or continuous mode. 

    Best regards,

    Ryan Ma

  • I had reviewed the examples, however this program was set up using SYSCONFIG.

  • The ecap configuration is contained in the 3 ecap control registers ECCTL0 - ECCTL2 listed above.  The TRM has a key to the registers in the ecap chapter. I am attempting (so far unsuccessfully) to measure duty cycle by (Cap2 - Cap1) in the interrupt routine.  Cap1 is loaded on the rising edge and Cap2 is loaded on the falling edge.

  • Hi Gary,

    Could you try loading the .out of the syscfg examples (ecap_ex2_capture_pwm), you can also refer to the code that is generated using driverlib from SysConfig to help configure your own settings.

    For example the below snippet (taken from SysConfig) will configure eCAP to monitor an input XBAR signal as capture the duty/period.

    void myECAP0_init(){
    	//
    	// Disable ,clear all capture flags and interrupts
    	//
    	ECAP_disableInterrupt(myECAP0_BASE,
    		(ECAP_ISR_SOURCE_CAPTURE_EVENT_1  |
    		ECAP_ISR_SOURCE_CAPTURE_EVENT_2  |
    		ECAP_ISR_SOURCE_CAPTURE_EVENT_3  |
    		ECAP_ISR_SOURCE_CAPTURE_EVENT_4  |
    		ECAP_ISR_SOURCE_COUNTER_OVERFLOW |
    		ECAP_ISR_SOURCE_COUNTER_PERIOD   |
    		ECAP_ISR_SOURCE_COUNTER_COMPARE));
    	ECAP_clearInterrupt(myECAP0_BASE,
    		(ECAP_ISR_SOURCE_CAPTURE_EVENT_1  |
    		ECAP_ISR_SOURCE_CAPTURE_EVENT_2  |
    		ECAP_ISR_SOURCE_CAPTURE_EVENT_3  |
    		ECAP_ISR_SOURCE_CAPTURE_EVENT_4  |
    		ECAP_ISR_SOURCE_COUNTER_OVERFLOW |
    		ECAP_ISR_SOURCE_COUNTER_PERIOD   |
    		ECAP_ISR_SOURCE_COUNTER_COMPARE));
    	//
    	// Disables time stamp capture.
    	//
    	ECAP_disableTimeStampCapture(myECAP0_BASE);
    	//
    	// Stops Time stamp counter.
    	//
    	ECAP_stopCounter(myECAP0_BASE);
    	//
    	// Sets eCAP in Capture mode.
    	//
    	ECAP_enableCaptureMode(myECAP0_BASE);
    	//
    	// Sets the capture mode.
    	//
    	ECAP_setCaptureMode(myECAP0_BASE,ECAP_CONTINUOUS_CAPTURE_MODE,ECAP_EVENT_4);
    	//
    	// Sets the Capture event prescaler.
    	//
    	ECAP_setEventPrescaler(myECAP0_BASE, 0U);
    	//
    	// Sets the Capture event polarity.
    	//
    	ECAP_setEventPolarity(myECAP0_BASE,ECAP_EVENT_1,ECAP_EVNT_FALLING_EDGE);
    	ECAP_setEventPolarity(myECAP0_BASE,ECAP_EVENT_2,ECAP_EVNT_RISING_EDGE);
    	ECAP_setEventPolarity(myECAP0_BASE,ECAP_EVENT_3,ECAP_EVNT_FALLING_EDGE);
    	ECAP_setEventPolarity(myECAP0_BASE,ECAP_EVENT_4,ECAP_EVNT_RISING_EDGE);
    	//
    	// Configure counter reset on events
    	//
    	ECAP_enableCounterResetOnEvent(myECAP0_BASE,ECAP_EVENT_1);	
    	ECAP_enableCounterResetOnEvent(myECAP0_BASE,ECAP_EVENT_2);	
    	ECAP_enableCounterResetOnEvent(myECAP0_BASE,ECAP_EVENT_3);	
    	ECAP_enableCounterResetOnEvent(myECAP0_BASE,ECAP_EVENT_4);	
    	//
    	// Select eCAP input.
    	//
    	ECAP_selectECAPInput(myECAP0_BASE,ECAP_INPUT_INPUTXBAR7);
    	//
    	// Sets a phase shift value count.
    	//
    	ECAP_setPhaseShiftCount(myECAP0_BASE,0U);
    	//
    	// Enable counter loading with phase shift value.
    	//
    	ECAP_enableLoadCounter(myECAP0_BASE);
    	//
    	// Configures Sync out signal mode.
    	//
    	ECAP_setSyncOutMode(myECAP0_BASE,ECAP_SYNC_OUT_SYNCI);
    	//
    	// Configures emulation mode.
    	//
    	ECAP_setEmulationMode(myECAP0_BASE,ECAP_EMULATION_STOP);
    	//
    	// Starts Time stamp counter for myECAP0.
    	//
    	ECAP_startCounter(myECAP0_BASE);
    	//
    	// Enables time stamp capture for myECAP0.
    	//
    	ECAP_enableTimeStampCapture(myECAP0_BASE);
    	//
    	// Re-arms the eCAP module for myECAP0.
    	//
    	ECAP_reArm(myECAP0_BASE);
    	//
    	// Enables interrupt source for myECAP0.
    	//
    	ECAP_enableInterrupt(myECAP0_BASE,(ECAP_ISR_SOURCE_CAPTURE_EVENT_4));
    
    }

    Best regards,

    Ryan Ma

  • I have tried the example ecap_ex2_capture_pwm from C2000Ware 6 and cannot get it to build.

  • Hi Gary,

    What errors are you seeing? I can help with your build errors.

    I tested the eCAP initialization that I had sent you, and I was seeing the correct duty/period.

    Best regards,

    Ryan Ma

  • I get the following messages when attempting the build:

    [0]**** Build of configuration 'CPU1_RAM' for project 'ecap_ex2_capture_pwm' ****

    [1]"C:\\ti\\ccs2010\\ccs\\utils\\bin\\gmake" -k -j 8 all -O

    [2]Building file: "../ecap_ex2_capture_pwm.syscfg"
    [3]Invoking: SysConfig
    [4]"C:/ti/ccs2010/ccs/utils/sysconfig_1.25.0/sysconfig_cli.bat" --script "C:/Users/Gary/workspace_ccstheia/ecap_ex2_capture_pwm/ecap_ex2_capture_pwm.syscfg" -o "syscfg" -s "C:/ti/C2000Ware_6_00_00_00/.metadata/sdk.json" -d "F28003x" -p "100PZ" -r "F28003x_100PZ" --compiler ccs
    [5]Warning: SysConfig has been updated to use standard TI part numbers. The device TMS320F280037C has been automatically selected. If this is not the desired please open SysConfig to change it.
    [6]Running script...
    [7]Ignoring the following missing components: /driverlib/PeripheralComponents.js, /utilities/clb_tool/clb_syscfg/source/CLBToolComponents.js, /utilities/dcsm_tool/dcsm_syscfg/source/DCSMToolComponents.js, /utilities/cmd_tool/cmd_syscfg/source/CMDToolComponents.js, /libraries/C2000WARELibraryComponents.js, /driverlib/clocktree/clockTreeComponents.js, /utilities/transfer/TransferComponents.js
    [8]Error: Exception occurred calling scripting.addModule(): No such resource: /driverlib/ecap.js
    [9]Paths searched:
    [10]C:\ti\C2000Ware_6_00_00_00\driverlib\ecap.js
    [11]C:\ti\C2000Ware_6_00_00_00\driverlib\.meta\ecap.js
    [12]C:\ti\C2000Ware_6_00_00_00\.meta\driverlib\ecap.js
    [13]C:\Users\Gary\workspace_ccstheia\ecap_ex2_capture_pwm\driverlib\ecap.js
    [14]C:\Users\Gary\workspace_ccstheia\ecap_ex2_capture_pwm\driverlib\.meta\ecap.js
    [15]C:\Users\Gary\workspace_ccstheia\ecap_ex2_capture_pwm\.meta\driverlib\ecap.js
    [16] at Object.addModule (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\scripting\scriptingGuard.ts:52:10)
    [17] at scriptFunc (C:\Users\Gary\workspace_ccstheia\ecap_ex2_capture_pwm\ecap_ex2_capture_pwm.syscfg:5:30)
    [18] at cb (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\scripting\runScript.ts:123:13)
    [19] at withDeprecatedAccessAsync (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\deprecatedAccessGuard.ts:24:16)
    [20] at runAsUserScriptAsync (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\scripting\scriptingGuard.ts:93:16)
    [21] at runScripts (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\scripting\runScript.ts:121:11)
    [22] at sysConfig (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\scripting\runScript.ts:83:8)
    [23] at status (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\cli\cli_core.ts:103:8)
    [24] at t.runCLI (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\cli\runCli.ts:48:4)
    [25]gmake: *** [subdir_rules.mk:18: build-1217953697] Error 1
    [26]gmake: Target 'all' not remade because of errors.

    [27]**** Build finished ****

  • Hi Gary,

    Can you share your project's dependencies within CCS? I would also recommend updating CCS2010 to CCS2030 or the latest CCS.

    If you right click on your project, you can go to "properties...", then under General -> Dependencies -> ensure the correct version of SysConfig and SDK version is being used.

    Then try to rebuild 

    Best regards,

    Ryan Ma

  • It lists the dependencies as Sysconfig [1.25.0] and C2000Ware [6.0.0.00].  I am already using CCS2030 and updates are current.

  • Hi Gary,

    I was able to replicate the issue you were seeing. I had to delete the project from my workspace, reimport the project and try to rebuild it, and I was able to get it to build successfully.

    I am not sure where the error stemmed from as I am now unable to replicate it.

    Can you try to delete the example project and reimport it from the C2000WARE 6.0.0.00 location?

  • I was able to delete the project.  However, I have run into problems trying to create it again.  The Project Wizard keeps telling me that it is in the cloud and asks me to download it again.  It does not find it on the disk in the location where it put it on the previous download.  Endless loop.

  • Hi Gary,

    Are you running CCS locally?

    Can you try the following?

    Go to File -> Import Projects... ->

    Locate your c2000ware installation folder

    C:\ti\c2000\C2000Ware_6_00_00_00\driverlib\f28003x\examples\ecap

    Then import the example 2. 

    Best regards,

    Ryan Ma

  • Thanks.  I was able to load and create the project.  The current build messages are:

    [0]**** Clean-only build of configuration 'CPU1_RAM' for project 'ecap_ex2_capture_pwm' ****

    [1]"C:\\ti\\ccs2010\\ccs\\utils\\bin\\gmake" -k -j 8 clean -O

    [2]**** Build finished ****

    [3]**** Build of configuration 'CPU1_RAM' for project 'ecap_ex2_capture_pwm' ****

    [4]"C:\\ti\\ccs2010\\ccs\\utils\\bin\\gmake" -k -j 8 all -O

    [5]Building file: "../ecap_ex2_capture_pwm.syscfg"
    [6]Invoking: SysConfig
    [7]"C:/ti/ccs2010/ccs/utils/sysconfig_1.25.0/sysconfig_cli.bat" --script "C:/ti/C2000Ware_6_00_00_00/driverlib/f28003x/examples/ecap/ecap_ex2_capture_pwm/ecap_ex2_capture_pwm.syscfg" -o "syscfg" -s "C:/ti/C2000Ware_6_00_00_00/.metadata/sdk.json" -d "F28003x" -p "100PZ" -r "F28003x_100PZ" --compiler ccs
    [8]Warning: SysConfig has been updated to use standard TI part numbers. The device TMS320F280037C has been automatically selected. If this is not the desired please open SysConfig to change it.
    [9]Running script...
    [10]Ignoring the following missing components: /driverlib/PeripheralComponents.js, /utilities/clb_tool/clb_syscfg/source/CLBToolComponents.js, /utilities/dcsm_tool/dcsm_syscfg/source/DCSMToolComponents.js, /utilities/cmd_tool/cmd_syscfg/source/CMDToolComponents.js, /libraries/C2000WARELibraryComponents.js, /driverlib/clocktree/clockTreeComponents.js, /utilities/transfer/TransferComponents.js
    [11]Error: Exception occurred calling scripting.addModule(): No such resource: /driverlib/ecap.js
    [12]Paths searched:
    [13]C:\ti\C2000Ware_6_00_00_00\driverlib\ecap.js
    [14]C:\ti\C2000Ware_6_00_00_00\driverlib\.meta\ecap.js
    [15]C:\ti\C2000Ware_6_00_00_00\.meta\driverlib\ecap.js
    [16]C:\ti\C2000Ware_6_00_00_00\driverlib\f28003x\examples\ecap\ecap_ex2_capture_pwm\driverlib\ecap.js
    [17]C:\ti\C2000Ware_6_00_00_00\driverlib\f28003x\examples\ecap\ecap_ex2_capture_pwm\driverlib\.meta\ecap.js
    [18]C:\ti\C2000Ware_6_00_00_00\driverlib\f28003x\examples\ecap\ecap_ex2_capture_pwm\.meta\driverlib\ecap.js
    [19] at Object.addModule (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\scripting\scriptingGuard.ts:52:10)
    [20] at scriptFunc (C:\ti\C2000Ware_6_00_00_00\driverlib\f28003x\examples\ecap\ecap_ex2_capture_pwm\ecap_ex2_capture_pwm.syscfg:5:30)
    [21] at cb (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\scripting\runScript.ts:123:13)
    [22] at withDeprecatedAccessAsync (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\deprecatedAccessGuard.ts:24:16)
    [23] at runAsUserScriptAsync (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\scripting\scriptingGuard.ts:93:16)
    [24] at runScripts (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\scripting\runScript.ts:121:11)
    [25] at sysConfig (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\pinmux\services\scripting\runScript.ts:83:8)
    [26] at status (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\cli\cli_core.ts:103:8)
    [27] at t.runCLI (C:\ti\ccs2010\ccs\utils\sysconfig_1.25.0\dist\webpack:\sysconfig\src\cli\runCli.ts:48:4)
    [28]gmake: *** [subdir_rules.mk:18: build-1217953697] Error 1
    [29]gmake: Target 'all' not remade because of errors.

    [30]**** Build finished ****

  • Hi Gary,

    Looks like you're still seeing the same issue.

    [11]Error: Exception occurred calling scripting.addModule(): No such resource: /driverlib/ecap.js

    I will need to forward this to our software team.

    Best regards,

    Ryan Ma

  • Have you heard anything from the software team?

  • Hi Gary,

    The ecap.js file is present in C:\ti\c2000\C2000Ware_6_00_00_00\c2000ware\driverlib\.meta\ecap.js.

    Are you able to locate this file locally? 

    I would suggest you to use the latest C2000Ware SDK package - C2000WARE Software development kit (SDK) | TI.com (version 6.00.01).

    Delete the example from the workspace and try reimporting from the latest 6.00.01 SDK release. There might be some files got deleted from the older installed SDK package and CCS is trying to locate them and they are not found.

    Please try the latest SDK and let me know your observations.

    Thanks

    Aswin