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-F28P65X: CMPSS ASysCtl generating CPU1 code on CPU2 from SysConfig

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

When configuring on SysConfig the CMPxPMXSEL on each CMPSS on CPU2, the generated code for ASysCtl for configuring CMPxPMXSEL is placed on CPU2, but ASysCtl can't be accessed by CPU2, so no config is applied.

The current workaround i'm using is configuring ASysCtl manually on init code.

Regards,
Jesús

  • Hi Jesus,

    Currently ASysCtl registers (including CMPxPMXSEL) are only writable from CPU1 and that generated code is placed in the CPU1 context. Hence you cannot configure them from CPU2 sysconfig, this is a dual core sys config limitation.

    Thanks,

    Ira

  • Yeah, i know that register is only writable from CPU1. But when you configure CMPSS from CPU2 on SysConfig the generated code related to setting CMPxPMXSEL is placed on CPU2. I think that not beign able to configure CMPSS correctly due to CMPxPMXSEL not being available on CPU2. Maybe a solution is moving the configuration part of CMPxPMXSEL from CMPSS to ASysCtl config that is only available on CPU1 sysconfig tab.

  • Also, looking at C2000Ware on .meta this can be resolved moving the ASysCtl part from cmpss.board.c.xdt to asysctl.board.c.xdt. I've tested this fix and it generates the code correctly.

  • Hi Jesus,

    Let me discuss this with the correct experts on the c2000ware team and provide a reply by monday eod.

    Thanks,

    Ira

  • Hi Jesus,

    Sorry for the late reply as I was OOO. This is a sys config limitation and ASYSCTL registers are only accessible by CPU1 on the F28P65x, but SysConfig incorrectly generates the CMPxPMXSEL configuration code within the CPU2 project when CMPSS instances are configured on CPU2. Manually configuring the ASYSCTL CMPxPMXSEL registers in CPU1's initialization code (before calling Device_bootCPU2()) is the proper approach. This ensures the analog mux selections are applied before CPU2 begins using the CMPSS peripherals. Can you confirm which version of CCS and C2000Ware you are using?

    Thanks,

    Ira

  • Hi,

    I'm using CCS 12.8.1 and C2000Ware 26.00.00.00, the latest that bug fixes are included, as release notes indicates. Currently I'm configuring the registers manually on CPU1, but I have a patch for .meta files that places the generated code on the right CPU (found attached the patched files with removed .xdt extension).

    % var module = system.modules['/driverlib/asysctl.js'];
    % let Common   = system.getScript("/driverlib/Common.js");
    % var nameOfModule = "asysctl";
    % var nameOfPeripheral = module.peripheralName;
    //*****************************************************************************
    //
    // ASYSCTL Configurations
    //
    //*****************************************************************************
    void `nameOfPeripheral`_init(){
    %if (module != null)
    %{
    % var stat = module.$static
    	//
    	// `nameOfModule` initialization
    %		if(stat.enableTemperatureSensor){
    	//
    	// Enables the temperature sensor output to the ADC.
    	//
    	ASysCtl_enableTemperatureSensor();
    	DEVICE_DELAY_US(500);
    %		}
    %		else{
    	//
    	// Disables the temperature sensor output to the ADC.
    	//
    	ASysCtl_disableTemperatureSensor();
    %		}
    %		if(stat.lockTemperatureSensor){
    	//
    	// Locks the temperature sensor control register.
    	//
    	ASysCtl_lockTemperatureSensor();
    %		}
    %		if(["F28004x", "F28P65x"].includes(system.deviceData.deviceId)){
    %			if(stat.analogReference == "INTERNAL"){
    	//
    	// Set the analog voltage reference selection to internal.
    	//
    	ASysCtl_setAnalogReferenceInternal( ASYSCTL_VREFHIA | ASYSCTL_VREFHIB | ASYSCTL_VREFHIC );
    %			}
    %			else{
    	//
    	// Set the analog voltage reference selection to external.
    	//
    	ASysCtl_setAnalogReferenceExternal( ASYSCTL_VREFHIA | ASYSCTL_VREFHIB | ASYSCTL_VREFHIC );
    %			}
    %			if((stat.analogReference == "INTERNAL") && (stat.analogReferenceVoltage == "2P5")){
    	//
    	// Set the internal analog voltage reference selection to 2.5V.
    	//
    	ASysCtl_setAnalogReference2P5( ASYSCTL_VREFHIA | ASYSCTL_VREFHIB | ASYSCTL_VREFHIC );
    %			}
    %			else if((stat.analogReference == "INTERNAL") && (stat.analogReferenceVoltage == "1P65")){
    	//
    	// Set the internal analog voltage reference selection to 1.65V.
    	//
    	ASysCtl_setAnalogReference1P65( ASYSCTL_VREFHIA | ASYSCTL_VREFHIB | ASYSCTL_VREFHIC );
    %			}
    %		}
    %		else if(system.deviceData.deviceId.includes("F28002x")){
    %			if(stat.analogReference == "INTERNAL"){
    	//
    	// Set the analog voltage reference selection to internal.
    	//
    	ASysCtl_setAnalogReferenceInternal( ASYSCTL_VREFHIA | ASYSCTL_VREFHIC );
    %			}
    %			else{
    	//
    	// Set the analog voltage reference selection to external.
    	//
    	ASysCtl_setAnalogReferenceExternal( ASYSCTL_VREFHIA | ASYSCTL_VREFHIC );
    %			}
    %			if((stat.analogReference == "INTERNAL") && (stat.analogReferenceVoltage == "2P5")){
    	//
    	// Set the internal analog voltage reference selection to 2.5V.
    	//
    	ASysCtl_setAnalogReference2P5( ASYSCTL_VREFHIA | ASYSCTL_VREFHIC );
    %			}
    %			else if((stat.analogReference == "INTERNAL") && (stat.analogReferenceVoltage == "1P65")){
    	//
    	// Set the internal analog voltage reference selection to 1.65V.
    	//
    	ASysCtl_setAnalogReference1P65( ASYSCTL_VREFHIA | ASYSCTL_VREFHIC );
    %			}
    %		}
    % 		else if( ["F28003x", "F280013x", "F280015x", "F28E12x", "MCPC029"].includes(system.deviceData.deviceId)){
    %			if(stat.analogReference == "INTERNAL"){
    	//
    	// Set the analog voltage reference selection to internal.
    	//
    	ASysCtl_setAnalogReferenceInternal( ASYSCTL_VREFHI );
    %			}
    %			else{
    %					if(!(["F280013x", "F280015x"].includes(system.deviceData.deviceId) && ["32RHB"].includes(system.deviceData.package))){
    	//
    	// Set the analog voltage reference selection to external.
    	//
    	ASysCtl_setAnalogReferenceExternal( ASYSCTL_VREFHI );
    %					}
    %			}
    %			if((stat.analogReference == "INTERNAL") && (stat.analogReferenceVoltage == "2P5")){
    	//
    	// Set the internal analog voltage reference selection to 2.5V.
    	//
    	ASysCtl_setAnalogReference2P5( ASYSCTL_VREFHI);
    %			}
    %			else if((stat.analogReference == "INTERNAL") && (stat.analogReferenceVoltage == "1P65")){
    	//
    	// Set the internal analog voltage reference selection to 1.65V.
    	//
    	ASysCtl_setAnalogReference1P65( ASYSCTL_VREFHI );
    %			}
    %		}
    % 		else if( ["F28P55x","F28P551x"].includes(system.deviceData.deviceId)){
    %			if(stat.analogReference == "INTERNAL"){
    	//
    	// Set the analog voltage reference selection to internal.
    	//
    	ASysCtl_setAnalogReferenceInternal( ASYSCTL_ANAREF_INTREF_ADCA | ASYSCTL_ANAREF_INTREF_ADCB | ASYSCTL_ANAREF_INTREF_ADCC | ASYSCTL_ANAREF_INTREF_ADCD | ASYSCTL_ANAREF_INTREF_ADCE );
    %			}
    %			else if(stat.analogReference == "EXTERNAL"){
    	//
    	// Set the analog voltage reference selection to external.
    	//
    	ASysCtl_setAnalogReferenceExternal( ASYSCTL_ANAREF_VREFHI_ADCA | ASYSCTL_ANAREF_VREFHI_ADCB | ASYSCTL_ANAREF_VREFHI_ADCC | ASYSCTL_ANAREF_VREFHI_ADCD | ASYSCTL_ANAREF_VREFHI_ADCE );
    %			}
    %			else if(stat.analogReference == "VDDA"){
    	//
    	// Set the analog voltage reference selection to VDDA.
    	//
    	ASysCtl_setAnalogReferenceVDDA( ASYSCTL_ANAREF_VDDA_ADCA | ASYSCTL_ANAREF_VDDA_ADCB | ASYSCTL_ANAREF_VDDA_ADCC | ASYSCTL_ANAREF_VDDA_ADCD | ASYSCTL_ANAREF_VDDA_ADCE );
    %			}
    
    %			if((stat.analogReference == "INTERNAL") && (stat.analogReferenceVoltage == "2P5")){
    	//
    	// Set the internal analog voltage reference selection to 2.5V.
    	//
    	ASysCtl_setAnalogReference2P5( ASYSCTL_ANAREF_ADCA | ASYSCTL_ANAREF_ADCB | ASYSCTL_ANAREF_ADCC | ASYSCTL_ANAREF_ADCD | ASYSCTL_ANAREF_ADCE );
    %			}
    %			else if((stat.analogReference == "INTERNAL") && (stat.analogReferenceVoltage == "1P65")){
    	//
    	// Set the internal analog voltage reference selection to 1.65V.
    	//
    	ASysCtl_setAnalogReference1P65( ASYSCTL_ANAREF_ADCA | ASYSCTL_ANAREF_ADCB | ASYSCTL_ANAREF_ADCC | ASYSCTL_ANAREF_ADCD | ASYSCTL_ANAREF_ADCE );
    %			}
    %		}
    %}
    %if((system.deviceData.deviceId.includes("F28P55x")||system.deviceData.deviceId.includes("F28P551x") || system.deviceData.deviceId.includes("F280013x") || system.deviceData.deviceId.includes("F280015x")) && (stat.externalDACLEnable == true))
    %{
    	//
    	// This function disables CMPSSx.COMPL and the associated DAC will act as a
    	// general purpose DAC with 11 bit resolution
    	//
    	ASysCtl_enableCMPSSExternalDAC(ASYSCTL_CMPSS1_DACL);
    %}
    %if((["F28E12x", "MCPC029"].includes(system.deviceData.deviceId)) && (stat.externalDACLEnable == true))
    %{
    	//
    	// This function disables CMPSSx.COMPL and the associated DAC will act as a
    	// general purpose DAC with 11 bit resolution
    	//
    	ASysCtl_enableCMPSSExternalDAC(ASYSCTL_CMPSS3_DACL);
    %}
    % // For devices where ASysCtl is only accessible from CPU1, generate the
    % // ASysCtl_selectCMP* MUX calls for CMPSS instances from ALL contexts.
    % if (["F28002x", "F28003x", "F28004x", "F280013x", "F280015x", "F28P65x", "F28P55x", "F28P551x"].includes(system.deviceData.deviceId)) {
    %     var allContextNames = Common.getContextNames();
    %     for (var cntx of allContextNames) {
    %         var cmpssModule = Common.getModuleForCore('/driverlib/cmpss.js', cntx);
    %         if (cmpssModule && cmpssModule.$instances.length > 0) {
    	//
    	// CMPSS ASysCtl MUX selections for context: `cntx`
    	//
    %             for (var i = 0; i < cmpssModule.$instances.length; i++) {
    %                 var cmpssInst = cmpssModule.$instances[i];
    	ASysCtl_selectCMPHPMux(`cmpssInst.$name`_CMPHPMUX_SELECT, `cmpssInst.asysCMPHPMXSELValue`U);
    %                 if (cmpssInst.highCompNegative != "CMPSS_INSRC_DAC") {
    	ASysCtl_selectCMPHNMuxValue(`cmpssInst.$name`_CMPHNMUX_SELECT, `cmpssInst.asysCMPHNMXSELValue`U);
    %                 }
    	ASysCtl_selectCMPLPMux(`cmpssInst.$name`_CMPLPMUX_SELECT, `cmpssInst.asysCMPLPMXSELValue`U);
    %                 if (cmpssInst.lowCompNegative != "CMPSS_INSRC_DAC") {
    	ASysCtl_selectCMPLNMuxValue(`cmpssInst.$name`_CMPLNMUX_SELECT, `cmpssInst.asysCMPLNMXSELValue`U);
    %                 }
    %             }
    %         }
    %     }
    % }
    }
    
    asysctl.board.h
    % var module = system.modules['/driverlib/cmpss.js'];
    % let Common   = system.getScript("/driverlib/Common.js");
    % var nameOfModule = "cmpss";
    % var nameOfPeripheral = module.peripheralName;
    %
    //*****************************************************************************
    //
    // CMPSS Configurations
    //
    //*****************************************************************************
    void `nameOfPeripheral`_init(){
    %   for(var i = 0; i < module.$instances.length; i++) 
    %   {
    %      var instance = module.$instances[i];
    	`instance.$name`_init();
    %   }
    }
    
    %if (module != null)
    % {
            % for(var i = 0; i < module.$instances.length; i++) {
                % var instance = module.$instances[i];
                % var instanceNumber = instance.cmpssBase.match(/\d+/)[0]
    void `instance.$name`_init(){
            % var baseName = instance.$name + "_BASE";
    %%{
        var configHighString = "("
        configHighString += instance.highCompNegative
        if (instance.highCompInvert){
            configHighString += " | CMPSS_INV_INVERTED"
        }
        if (instance.highCompAsynch){
            configHighString += " | CMPSS_OR_ASYNC_OUT_W_FILT"
        }
        configHighString += ")"
    %%}
        //
        // Sets the configuration for the high comparator.
        //
        CMPSS_configHighComparator(`baseName`,`configHighString`);
    %%{
        var configLowString = "("
        configLowString += instance.lowCompNegative
        if (instance.lowCompInvert){
            configLowString += " | CMPSS_INV_INVERTED"
        }
        if (instance.lowCompAsynch){
            configLowString += " | CMPSS_OR_ASYNC_OUT_W_FILT"
        }
        configLowString += ")"
    %%}
        //
        // Sets the configuration for the low comparator.
        //
        CMPSS_configLowComparator(`baseName`,`configLowString`);
        //
        // Sets the configuration for the internal comparator DACs.
        //
            % if(instance.dacValLoad == "CMPSS_DACVAL_PWMSYNC"){
        //
        //  - ePWM module must be configured before using here.
        //
            % }
    	% if(["F2807x", "F2837xS", "F2837xD", "F2838x", "F28002x", "F28003x","F28004x"].includes(system.deviceData.deviceId)){
        CMPSS_configDAC(`baseName`,(`instance.dacValLoad` | `instance.dacRefVoltage` | `instance.dacValSource`));
            % }
            % if(["F280013x"].includes(system.deviceData.deviceId)){
        CMPSS_configDAC(`baseName`,(`instance.dacValLoad` | `instance.dacValSource`));
            % }
    	% if(["F28P65x"].includes(system.deviceData.deviceId)){
        CMPSS_configDACHigh(`baseName`,(`instance.dacValLoad` | `instance.dacRefVoltage` | `instance.dacValSource`));
            % }
    	% if(["F280015x", "F28P55x","F28P551x"].includes(system.deviceData.deviceId)){
        CMPSS_configDACHigh(`baseName`,(`instance.dacValLoad` | `instance.dacValSource`));
            % }
    	% if(["F280015x", "F28P65x", "F28P55x","F28P551x"].includes(system.deviceData.deviceId)){
        CMPSS_configDACLow(`baseName`, `instance.lowDacValSource`);
            % }
        //
        // Sets the value of the internal DAC of the high comparator.
        //
        CMPSS_setDACValueHigh(`baseName`,`instance.dacValHigh`U);
        //
        // Sets the value of the internal DAC of the low comparator.
        //
        CMPSS_setDACValueLow(`baseName`,`instance.dacValLow`U);
        % if((["F28P65x"].includes(system.deviceData.deviceId)) && (instance.deEnable == true)){
        //
        // Enable Diode Emulation Support for CMPSS
        //
        CMPSS_enableDEmode(`baseName`);
        %}
        % if(["F28P65x"].includes(system.deviceData.deviceId)){
        //
        // Sets the value of the internal DAC of the high comparator for Diode Emulation Support.
        //
        CMPSS_configHighDACShadowValueDE(`baseName`, `instance.deDACValHigh`U);
        //
        // Sets the value of the internal DAC of the low comparator for Diode Emulation Support.
        //
        CMPSS_configLowDACShadowValueDE(`baseName`, `instance.deDACValLow`U);
        //
        // Set the DEACTIVE signal source for CMPSS
        //
        CMPSS_selectDEACTIVESource(`baseName`, `instance.deactiveSel`);
        % }
        //
        //  Configures the digital filter of the high comparator.
        //
        CMPSS_configFilterHigh(`baseName`, `instance.samplePrescaleHigh`U, `instance.sampleWindowHigh`U, `instance.thresholdHigh`U);
        //
        // Configures the digital filter of the low comparator.
        //
        CMPSS_configFilterLow(`baseName`, `instance.samplePrescaleLow`U, `instance.sampleWindowLow`U, `instance.thresholdLow`U);
            % if(instance.initFilterHigh){
        //
        // Initializes the digital filter of the high comparator.
        //
        CMPSS_initFilterHigh(`baseName`);
            % }
            % if(instance.initFilterLow){
        //
        // Initializes the digital filter of the low comparator.
        //
        CMPSS_initFilterLow(`baseName`);
            % }
        //
        // Sets the output signal configuration for the high comparator.
        //
        CMPSS_configOutputsHigh(`baseName`,(`instance.highCTRIPOUT` | `instance.highCTRIP`));
        //
        // Sets the output signal configuration for the low comparator.
        //
        CMPSS_configOutputsLow(`baseName`,(`instance.lowCTRIPOUT` | `instance.lowCTRIP`));
        //
        // Sets the comparator hysteresis settings.
        //
        CMPSS_setHysteresis(`baseName`,`instance.hysteresisVal`U);
        % if(["F280015x", "F28P65x", "F28P55x","F28P551x"].includes(system.deviceData.deviceId)){
        //
        // Configures the comparator subsystem's high ramp generator.
        //
        CMPSS_configRampHigh(`baseName`, `instance.rampHighDir`, `instance.maxRampVal`U,`instance.ramDecVal`U,`instance.rampDelayVal`U,`instance.pwmSyncSrc`U,`instance.useRampValShdw`);
        //
        // Configures the comparator subsystem's low ramp generator.
        //
        CMPSS_configRampLow(`baseName`, `instance.rampLowDir`, `instance.maxRampValLow`U,`instance.ramDecValLow`U,`instance.rampDelayValLow`U,`instance.pwmSyncSrcLow`U,`instance.useRampValShdwLow`);
        %}
        %else
        %{
        //
        // Configures the comparator subsystem's ramp generator.
        //
        CMPSS_configRamp(`baseName`,`instance.maxRampVal`U,`instance.ramDecVal`U,`instance.rampDelayVal`U,`instance.pwmSyncSrc`U,`instance.useRampValShdw`);
        %}
        % if( ["F28P65x", "F28P55x","F28P551x"].includes(system.deviceData.deviceId)){
        //
        // Configures the high comparator's ramp generator clock divider
        //
        CMPSS_setRampClockDividerHigh(`baseName`, `instance.rampClkDiv`);
        //
        // Configures the low comparator's ramp generator clock divider
        //
        CMPSS_setRampClockDividerLow(`baseName`, `instance.rampClkDivLow`);
        %}
            % if(instance.latchResetHigh){
        //
        // Enables reset of HIGH comparator digital filter output latch on PWMSYNC
        //
        CMPSS_enableLatchResetOnPWMSYNCHigh(`baseName`);
            % }
            % else{
        //
        // Disables reset of HIGH comparator digital filter output latch on PWMSYNC
        //
        CMPSS_disableLatchResetOnPWMSYNCHigh(`baseName`);
            % }
            % if(instance.latchResetLow){
        //
        // Enables reset of LOW comparator digital filter output latch on PWMSYNC
        //
        CMPSS_enableLatchResetOnPWMSYNCLow(`baseName`);
            % }
            % else{
        //
        // Disables reset of LOW comparator digital filter output latch on PWMSYNC
        //
        CMPSS_disableLatchResetOnPWMSYNCLow(`baseName`);
            % }
            % if( ["F28002x", "F28003x", "F28004x","F2838x", "F280013x", "F280015x", "F28P65x", "F28P55x","F28P551x"].includes(Common.getDeviceName())){
        //
        // Sets the ePWM module blanking signal that holds trip in reset.
        //
        CMPSS_configBlanking(`baseName`,`instance.configBlanking`U);
                % if(instance.enableBlanking){
        //
        // Enables an ePWM blanking signal to hold trip in reset.
        //
        CMPSS_enableBlanking(`baseName`);
                % }
                % else{
        //
        // Disables an ePWM blanking signal from holding trip in reset.
        //
        CMPSS_disableBlanking(`baseName`);
                % }
            % }
        //
        // Configures whether or not the digital filter latches are reset by PWMSYNC
        //
        CMPSS_configLatchOnPWMSYNC(`baseName`,`instance.configLatchHigh`,`instance.configLatchLow`);
            % if(instance.enableModule){
        //
        // Enables the CMPSS module.
        //
        CMPSS_enableModule(`baseName`);
            % }
            % else{
        //
        // Disables the CMPSS module.
        //
        CMPSS_disableModule(`baseName`);
    
            % }
        //
        // Delay for CMPSS DAC to power up.
        //
        DEVICE_DELAY_US(500);
            % if(instance.clearFilterLatchHigh){
        //
        // Causes a software reset of the high comparator digital filter output latch.
        //
        CMPSS_clearFilterLatchHigh(`baseName`);
        % }
            % if(instance.clearFilterLatchLow){
        //
        // Causes a software reset of the low comparator digital filter output latch.
        //
        CMPSS_clearFilterLatchLow(`baseName`);
        % }
    }
        % }
    % }

  • Yep, this is a current sys config limitation, and it is best to use the workaround for now.

    Thanks,

    Ira