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.

TMS320F28379D: SYSCONFIG Input XBAR Config Should Select By GPIO Name If Available.

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Hello ,

It would be better if I could select Input XBAR source by GPIO name.

For example, I've already set-up my GPIO input called 'HW_FLT_LATCH' on GPIO91 and I want to use it as an EPWM trip-zone trigger. But when I go to choose this input as the INPUT Source, I have to select GPIO91. I would like to choose HW_FLT_LATCH because it is confirmation I am choosing the correct input pin.

Thank you.

Kier.

  • That's a good point. INPUT XBAR can also select ANY GPIO, meaning that the scenario below is valid:

    SCIA is used as mySCIXYZ.

    It has to pins, RX and TX.

    These RX and TX are also available to be used as INPUTs to the INPUTXBAR, even if they are OUTPUT pins.

    I think we can have two possible solutions (one much easier to implement and maintain than the other):

    1. After you selected GPIO91, underneath it, in GRAY (uneditable) we did a search of all used PINMUXes to see if GPIO91 is used by any other module.

    This is easier to implement.

    2. Now this would be difficult, but the drop down would just show all GPIOs and all other peripheral GPIOs and the name of the module. This is a bit tough to do and manage.

  • What do you think? #1 would suffice?

  • #1 sounds good enough but what would the gray text say, for example? Maybe I don't quite understand the proposal. Sorry/

  • Let me mock up a demo and I'll show you!

     

    Thank you,
    Nima Eskandari
    C2000 Application Manager

  • Kier,

    It took hours to put together but this is what it looks like:

    Nima

  • Basically you have the GPIO used in other modules show up:

    So in this case GPIO3 is used by EPWM2B.

    So in the INPUT XBAR you would see:

  • Many thanks for the long hours making the mock-up but my understanding is that the Input X-BAR sources can only be GPIO inputs so I'm a bit confused why other modules (e.g. ePWM) are relevant.

    I'm asking that instead of having to select GPIO91, I can select by name of GPIO91 if I've given it one. e.g.:

    Apologies, maybe I should have put this pic in the original post.

  • So you are correct. INPUT XBAR can only take GPIOs. But if that specific GPIO is connected to EPWMxA/B outputs, it will still be routed back into the device.

    So the scenario where you ACTUALLY USE A GPIO as a GPIO for SW control of the pin is also supported. look at this:

    Then in the INPUT XBAR if GPIO 28 is selected:

  • is also supported

    You mean supported after you implement option #1?

  • Yes in my local setup it is now supported! We should have another release early next year!

    We also do have a BETA release program.

  • That works for me. Thank you very much!

  • Alright I will have this in the planning. Did you want to try it out? I can show you how to update your system to try it.

  • Yes, please.

  • I will send you the instructions + the updated files here.

    Nima

  • Kier,

    There are two files you need update in:

    C2000WARE/driverlib/.meta folder

    Common.js and inputxbar_input.js

    Both of them are attached here:

    let Common   = system.getScript("/driverlib/Common.js");
    let Pinmux   = system.getScript("/driverlib/pinmux.js");
    let InputXbar_DevSpecific  = system.getScript("/driverlib/inputxbar/inputxbar_deviceSpecific.js");
    
    let device_driverlib_peripheral = 
        system.getScript("/driverlib/device_driverlib_peripherals/" + 
            Common.getDeviceName().toLowerCase() + "_xbar.js");
    
    /* Intro splash on GUI */
    let longDescription = "The Input X-BAR is used to route signals from a GPIO to many different" +
                        " IP blocks such as the ADC(s), eCAP(s), ePWM(s), and external interrupts";
    
    var inputXbarCount = 16
    if (["F2837xD", "F2838xS", "F2807x"].includes(Common.getDeviceName()))
    {
        inputXbarCount = 14
    }
    
    
    /* Array of Input X-bar configurables that are common across device families */
    var config = [
    
    ];
    
    var gpios = Common.getGPIOs();
    var aios = Common.getAIOs();
    var inputxbarGPIOOptions = InputXbar_DevSpecific.getExtraInputOptions();
    for (var gpioIndex = 0; gpioIndex < gpios.length; gpioIndex++)
    {
        inputxbarGPIOOptions.push({name: gpios[gpioIndex]});
    }
    for (var aioIndex = 0; aioIndex < aios.length; aioIndex++)
    {
        inputxbarGPIOOptions.push({name: aios[aioIndex]});
    }
    
    var inputNumOptions = []
    for (var inputNum of device_driverlib_peripheral.XBAR_InputNum)
    {
        inputNumOptions.push({
            name: inputNum.name
        })
    }
    
    var inputxbarINPUTConfig = {
        name        : "inputxbarInput",
        displayName : "INPUT",
        description : 'The INPUT number for Input X-Bar',
        hidden      : false,
        default     : inputNumOptions[0].name,
        options     : inputNumOptions
    }
    
    var inputxbarGPIOConfig = {
        name        : "inputxbarGpio",
        displayName : "INPUT Source",
        description : 'GPIO for this Input X-Bar',
        hidden      : false,
        default     : inputxbarGPIOOptions[0].name,
        options     : inputxbarGPIOOptions
    }
    
    
    var inputxbarSelectedSourceConfig = {
        name        : "inputxbarSelectedSource",
        displayName : "Selected Source Of GPIO",
        description : 'Selected GPIO is connected to this signal in the application',
        hidden      : false,
        default     : "",
        getValue    : (inst) => {
            let modNames = Object.keys(system.modules).sort();
            for (var modName of modNames)
            {
                var mod = system.modules[modName]
                var pinmuxRequirementsFunc = mod.pinmuxRequirements;
                if (pinmuxRequirementsFunc)
                {
                    for (var modInstance of mod.$instances)
                    {
                        var pinmuxRequirements = pinmuxRequirementsFunc(modInstance);
                        //console.log(pinmuxRequirements)
                        for (var pinmuxReq of pinmuxRequirements)
                        {
                            var pinmuxReqName = pinmuxReq.name;
                            //console.log(pinmuxReqName)
                            if (pinmuxReq.resources)
                            {
                                //
                                // Normal Peripheral Other than GPIO
                                //
                                var peripheralName = modInstance[pinmuxReqName].$solution.peripheralName
                                //console.log(peripheralName)
                                for (var pinmuxReqInterface of pinmuxReq.resources)
                                {
                                    var pinmuxReqInterfaceName = pinmuxReqInterface.name
                                    var devicePinName = modInstance[pinmuxReqName][pinmuxReqInterfaceName].$solution.devicePinName
                                    var peripheralPinName = modInstance[pinmuxReqName][pinmuxReqInterfaceName].$solution.peripheralPinName
                                    //console.log(peripheralPinName)
                                    //console.log(devicePinName)
    
                                    var gpioNames = Pinmux.getGPIOFromDevicePinName(devicePinName)
                                    //console.log(gpioNames)
    
                                    if (gpioNames.includes(inst.inputxbarGpio))
                                    {
                                        //console.log("Found: " + modInstance.$name + " = " + peripheralPinName)
                                        return (modInstance.$name + " = " + peripheralPinName)
                                    }
                                }
                            }
                            else
                            {
                                //
                                // GPIO
                                //
                                var peripheralName = modInstance[pinmuxReqName].$solution.peripheralName
                                var devicePinName = modInstance[pinmuxReqName].$solution.devicePinName
                                var peripheralPinName = modInstance[pinmuxReqName].$solution.peripheralPinName
                                //console.log(peripheralName)
                                //console.log(peripheralPinName)
                                //console.log(devicePinName)
                                if (devicePinName)
                                {
                                    //
                                    // Normal GPIO, single bonded AGPIO
                                    //
                                    var gpioNames = Pinmux.getGPIOFromDevicePinName(devicePinName)
                                    //console.log(gpioNames)
                                    if (gpioNames.includes(inst.inputxbarGpio))
                                    {
                                        //console.log("Found: " + modInstance.$name + " = " + peripheralPinName)
                                        return (modInstance.$name + " = " + peripheralPinName)
                                    }
                                }
                                else
                                {
                                    //
                                    // Double bonded AGPIO and AIOs
                                    //
                                    if (peripheralName == inst.inputxbarGpio)
                                    {
                                        //console.log("Found: " + modInstance.$name + " = " + peripheralName)
                                        return (modInstance.$name + " = " + peripheralName)
                                    }
                                }
                            }
                        }
                        //console.log(pinmuxRequirementsFunc(modInstance))
                    }
                }
            }
            //console.log(system)
            return "This source is not used by any module"
        }
    }
    
    var inputxbarLOCKConfig = {
        name        : "inputxbarLock",
        displayName : "INPUT Lock",
        description : 'Lock this Input X-Bar',
        hidden      : false,
        default     : false
    }
    
    config.push(inputxbarINPUTConfig);
    config.push(inputxbarGPIOConfig);
    //config.push(inputxbarSelectedSourceConfig);
    config.push(inputxbarLOCKConfig);
    
    function onValidate(inst, validation)
    {
        var usedInsts = [];
        for (var instance_index in inst.$module.$instances)
        {
            var instance_obj = inst.$module.$instances[instance_index];
            usedInsts.push(instance_obj.inputxbarInput);
        }
        
        var duplicatesResult = Common.findDuplicates(usedInsts)
        
        if (duplicatesResult.duplicates.length != 0)
        {
            var allDuplicates = "";
            for (var duplicateNamesIndex in duplicatesResult.duplicates)
            {
                allDuplicates = allDuplicates + Common.stringOrEmpty(allDuplicates, ", ")
                                + duplicatesResult.duplicates[duplicateNamesIndex];
            }
            validation.logError(
                "This instance is already in use! Duplicates: " + allDuplicates,
                inst, "inputxbarInput");
        }
    }
    
    /*
     *  ======== filterHardware ========
     *  Control RX, TX Pin usage by the user specified dataDirection.
     *
     *  param component - hardware object describing signals and
     *                     resources they're attached to
     *
     *  returns Boolean indicating whether or not to allow the component to
     *           be assigned to an instance's $hardware config
     */
    function filterHardware(component)
    {
        return (Common.typeMatches(component.type, ["INPUTXBAR"]));
    }
    
    if (Common.onlyPinmux())
    {
        //config = [];
    }
    var inputxbarModule = {
        peripheralName: "INPUTXBAR",
        displayName: "INPUTXBAR INPUT",
        maxInstances: inputXbarCount,
        defaultInstanceName: "myINPUTXBARINPUT",
        description: "Input X-bar",
        filterHardware : filterHardware,
        config: config,
        validate  :  onValidate,
        templates: {
            boardc : "/driverlib/inputxbar/inputxbar_input.board.c.xdt",
            boardh : "/driverlib/inputxbar/inputxbar_input.board.h.xdt"
        },
        //pinmuxRequirements    : Pinmux.inputxbarPinmuxRequirements
    };
    
    
    if (inputxbarModule.maxInstances <= 0)
    {
        delete inputxbarModule.pinmuxRequirements;
    }
    
    
    exports = inputxbarModule;
    
    let CONTEXT_CPU1= "CPU1";
    let CONTEXT_CPU2= "CPU2";
    let CONTEXT_SYSTEM = "system"
    let Collateral  = system.getScript("/driverlib/sysconfig_collateral_links.js");
    
    exports = {
        getBoard : getBoard,
        getBoardName : getBoardName,
        getDeviceTRM: getDeviceTRM,
        getDeviceDatasheet: getDeviceDatasheet,
        findDuplicates : findDuplicates,
        peripheralCount: peripheralCount,
        typeMatches: typeMatches,
        peripheralNames: peripheralNames,
        stringOrEmpty: stringOrEmpty,
        removeNonNumber : removeNonNumber,
        gpioNameToNumber : gpioNameToNumber,
        printDebugObject : printDebugObject,
        printDebugObjectKeys : printDebugObjectKeys,
        getGPIOs : getGPIOs,
        getAIOs : getAIOs,
        peripheralListFromSysCtl : peripheralListFromSysCtl,
        getDeviceName: getDeviceName,
        getDevicePart: getDevicePart,
        getDevicePackage: getDevicePackage,
    	getSDK: getSDK,
    	onlyPinmux: onlyPinmux,
    	CLB_isType1 : CLB_isType1,
    	CLB_isType1_Type2 : CLB_isType1_Type2,
    	CLB_isType2 : CLB_isType2,
        autoForce : autoForce,
        autoForceMultiple : autoForceMultiple,
        SYSCLK_getMaxMHz : SYSCLK_getMaxMHz,
    	getConfigNameRecursive: getConfigNameRecursive,
        getConfigsRecursive: getConfigsRecursive,
        printConfigsInfo : printConfigsInfo,
        getCollateralFindabilityList : getCollateralFindabilityList,
    	zero_to_15        : [
            { name: 0 },
            { name: 1 },
            { name: 2 },
            { name: 3 },
            { name: 4 },
            { name: 5 },
            { name: 6 },
            { name: 7 },
            { name: 8 },
            { name: 9 },
            { name: 10 },
            { name: 11 },
            { name: 12 },
            { name: 13 },
            { name: 14 },
            { name: 15 },
    	],
    	zero_to_16        : [
            { name: 0 },
            { name: 1 },
            { name: 2 },
            { name: 3 },
            { name: 4 },
            { name: 5 },
            { name: 6 },
            { name: 7 },
            { name: 8 },
            { name: 9 },
            { name: 10 },
            { name: 11 },
            { name: 12 },
            { name: 13 },
            { name: 14 },
            { name: 15 },
            { name: 16 },
    	],
    
        CONTEXT_CPU1: CONTEXT_CPU1,
        CONTEXT_CPU2: CONTEXT_CPU2,
        isContextCPU1: isContextCPU1,
        isContextCPU2: isContextCPU2,
        isMultiCoreSysConfig : isMultiCoreSysConfig,
        isMultiCoreDevice : isMultiCoreDevice,
        getModuleForCore : getModuleForCore,
        getContextNames: getContextNames,
        getAllModulesForCore: getAllModulesForCore,
        getModulePaths, getModulePaths,
        getContextDisplayName: getContextDisplayName,
        getOtherContextNames: getOtherContextNames,
        isModuleOnThisContext: isModuleOnThisContext,
        isModuleOnAnyContext: isModuleOnAnyContext,
        isModuleOnOtherContext: isModuleOnOtherContext,
        getModuleForTheFirstAvailableCore : getModuleForTheFirstAvailableCore,
        removeArrayFromArray : removeArrayFromArray,
        getSYSCLK: getSYSCLK,
        getClockTree : getClockTree,
    };
    
    function getSYSCLK(cpu)
    {
        var clockTree = getClockTree();
        if (clockTree){
    
            if (isMultiCoreDevice())
            {
                if (!cpu)
                {
                    if (isContextCPU1())
                    {
                        cpu = "1"
                        return clockTree["CPU" + cpu + "_SYSCLK"].in
                    }
                    else
                    {
                        cpu = "2"
                        
                        return clockTree["CPU" + cpu + "_SYSCLK"].in
                    }
                }
            }
            else
            {
                return clockTree["SYSCLK"].in
            }
        }
        else
        {
            return SYSCLK_getMaxMHz()
        }
    }
    
    function removeArrayFromArray(arrSource, arrRem)
    {
        return arrSource.filter( function( el ) {
          return !arrRem.includes( el );
        } );
    }
    
    
    function getContextDisplayName(cntxName)
    {
        return (cntxName == CONTEXT_SYSTEM? CONTEXT_CPU1: cntxName)
    }
    
    function isContextCPU1()
    {
        if (system.context == CONTEXT_CPU1 || system.context == CONTEXT_SYSTEM)
        {
            return true;
        }
        return false
    }
    
    function isContextCPU2()
    {
        if (system.context == CONTEXT_CPU2)
        {
            return true;
        }
        return false
    }
    
    function getOtherContextNames()
    {
        var contextNames = Object.keys(system.contexts)
        return contextNames.filter(e => e !== system.context);
    }
    
    function isModuleOnThisContext(moduleName)
    {
        return system.modules[moduleName]?true:false;
    }
    
    function isModuleOnAnyContext(moduleName)
    {
        var cntxs = getContextNames();
        for (var cntx of cntxs){
            if (getModuleForCore(moduleName, cntx)){
                return true;
            }
        }
        return false;
    }
    
    function isModuleOnOtherContext(moduleName)
    {
        var cntxs = getOtherContextNames();
        for (var cntx of cntxs){
            if (getModuleForCore(moduleName, cntx)){
                return true;
            }
        }
        return false;
    }
    
    function getContextNames()
    {
        var contextNames = Object.keys(system.contexts)
        return contextNames;
    }
    
    //
    // Returns true only when the multi-core is laucnhed in sysconfig
    // If a multi-core device is launched in signle view it wont return true.
    //
    function isMultiCoreSysConfig()
    {   
        return (getContextNames().length > 1);
    }
    
    function isMultiCoreDevice()
    {   
        return (system.context.includes("CPU"));
    }
    
    function getAllModulesForCore(coreName)
    {
        let context = system.contexts[coreName];
        let modules = context ? context.system.modules : {};
    
        return modules;
    }
    
    //
    // Handles getting clocktree for multi-core this for multi-core
    //
    function getClockTree()
    {
        var contextNames = getContextNames();
        var mainContext = "system"
        if (contextNames.includes("CPU1"))
        {
            mainContext = "CPU1"
        }
        let context = system.contexts[mainContext];
        let clocktree = context ? context.system.clockTree : null;
    
        if (system.deviceData.clockTree)
        {
            return clocktree
        }
        else
        {
            return null
        }
    }
    
    function getModuleForCore(moduleName, coreName)
    {
        let context = system.contexts[coreName];
        let modules = context ? context.system.modules : {};
        let module = modules[moduleName];
    
        return module;
    }
    
    function getModuleForTheFirstAvailableCore(moduleName)
    {
        var cntxs = getContextNames();
        for (var cntx of cntxs){
            var mod = getModuleForCore(moduleName, cntx)
            if (mod){
                return mod;
            }
        }
        return null;
    }
    
    function getModulePaths(modules)
    {
        return Object.keys(modules).sort();;
    }
    
    function getBoard()
    {
        return system.deviceData.board;
    }
    
    
    function getBoardName()
    {
        if (system.deviceData.board)
        {
            return system.deviceData.board.name;
        }
        return null;
    }
    
    
    function getConfigNameRecursive(arrayConfigs)
    {
        var configNames = [];
        for (var modConfig of arrayConfigs)
        {        
            if (modConfig.config)
            {
                configNames = configNames.concat(getConfigNameRecursive(modConfig.config))
            }
            else
            {
                var modConfigName = modConfig.name;
                configNames.push(modConfigName);
            }
        }
        return configNames;
    }
    
    function getConfigsRecursive(arrayConfigs)
    {
        var configNames = [];
        for (var modConfig of arrayConfigs)
        {        
            if (modConfig.config)
            {
                configNames = configNames.concat(getConfigsRecursive(modConfig.config))
            }
            else
            {
                var modConfigName = modConfig;
                configNames.push(modConfigName);
            }
        }
        return configNames;
    }
    
    function printConfigsInfo(configByName)
    {
        // for (const key in configByName) {
        //     console.log(key);
        //     console.log(configByName[key].name)
        //     console.log(configByName[key].displayName)
        //     console.log(configByName[key].default)
        //     console.log(configByName[key].options)
        // }
        console.log(JSON.stringify(configByName, null, 4));
    }
    
    
    function autoForceMultiple(module_names_paths)
    {
        return (function (){
            return module_names_paths
        })
    
    }
    
    function autoForce(module_name, module_path)
    {
        return (function (){
            return [{
                name      : module_name,
                moduleName: module_path,
                hidden    : false
            }]
        })
    
    }
    
    function findDuplicates(arrayToCheck)
    {
        const count = arrayToCheck =>
          arrayToCheck.reduce((a, b) => ({ ...a,
            [b]: (a[b] || 0) + 1
          }), {})
    
        const duplicates = dict =>
          Object.keys(dict).filter((a) => dict[a] > 1)
    
        return {count: count(arrayToCheck), duplicates: duplicates(count(arrayToCheck))};
    }
    
    function onlyPinmux()
    {
    	return false;
    }
    
    function getSDK()
    {
    	var sdk = system.getScript("/.metadata/sdk.json");
    
        return sdk;
    }
    
    function getDeviceName()
    {
    	var deviceName = system.deviceData.device;
    	return deviceName
    }
    
    function getDevicePart()
    {
        var devicePart = system.deviceData.part;
        return devicePart
    }
    
    function getDevicePackage()
    {
        var devicePackage = system.deviceData.package;
        return devicePackage
    }
    
    function stringOrEmpty(stringToCheck, stringToAdd)
    {
        if (stringToCheck != "")
        {
            return stringToAdd;
        }
        return "";
    }
    
    function printDebugObject(obj)
    {
    	if (obj == null)
    	{
    		console.log("Object is null");
    		return;
    	}
        var keys = Object.keys(obj);
        for (var key in keys)
    	{
        	console.log(keys[key] + " : " + obj[keys[key]]);
        }
    }
    
    function printDebugObjectKeys(obj)
    {
        if (obj == null)
        {
            console.log("Object is null");
            return;
        }
        var keys = Object.keys(obj);
        console.log("Keys:")
        for (var key in keys)
        {
            console.log(keys[key]);
        }
    }
    
    function removeNonNumber(stringToCheck)
    {
    	var numberOnly = "";
        if (stringToCheck != "")
        {
        	for (var i = 0; i < stringToCheck.length; i++)
        	{
        		if ("0123456789".includes(stringToCheck[i]))
        		{
        			numberOnly += stringToCheck[i];
        		}
        	}
            return numberOnly;
        }
        return "";
    }
    
    //As soon a number is detected and then more characters are detected, exit.
    //Good for usecases like GPIO180_X2, the 2 is not added to the numbers
    function gpioNameToNumber(stringToCheck)
    {
    	var numberOnly = "";
    	var numbersDetected = false;
        if (stringToCheck != "")
        {
        	for (var i = 0; i < stringToCheck.length; i++)
        	{
        		if ("0123456789".includes(stringToCheck[i]))
        		{
        			numberOnly += stringToCheck[i];
        			numbersDetected = true;
        		}
        		else
        		{
        			if (numbersDetected)
            		{
            			return numberOnly;
            		}
        		}
        	}
            return numberOnly;
        }
        return "";
    }
    
    function getGPIOs()
    {
    	var allGpioNames = [];
    	let gpio = system.deviceData.interfaces.GPIO;
    	if (gpio != null)
    	{
    		for (var i = 0; i < gpio.peripherals.length; i++)
    		{
    			var gpioperiph = gpio.peripherals[i];
    			allGpioNames.push(gpioperiph.name);
    		}
    	}
    	return allGpioNames
    }
    
    function getAIOs()
    {
    	var allAioNames = [];
    	let aio = system.deviceData.interfaces.AIO;
    	if (aio != null)
    	{
    		for (var i = 0; i < aio.peripherals.length; i++)
    		{
    			var aioperiph = aio.peripherals[i];
    			allAioNames.push(aioperiph.name);
    		}
    	}
    	return allAioNames;
    }
    
    function peripheralListFromSysCtl(peripheralName, sysctl)
    {
        var peripherals = []
        sysctl.SysCtl_PeripheralPCLOCKCR.forEach((element, index) => {
            var split_by_underscore = element.name.split("_")
            var peripheralInst = split_by_underscore[split_by_underscore.length - 1];
            if (peripheralInst.startsWith(peripheralName))
            {
                peripherals.push(peripheralInst)
            }
        });
        return peripherals
    }
    
    function peripheralCount(peripheralType)
    {
    	let peripherals = system.deviceData.peripherals
    	let numberOfPeripherals = Object.keys(peripherals).length;
    	var count = 0;
    
    	//console.log(numberOfPeripherals);
    
    	for (var peripheral in peripherals) {
    
    	  	try
    	  	{
    	  		var interfaces = peripherals[peripheral]["interfaces"];
    	  		for (var interfaceType in interfaces)
    	  		{
    	  			if (peripheralType == interfaceType)
    	  			{
    	  				peripheralNames = interfaces[interfaceType].peripherals;
    	  				//console.log(peripheralNames);
    	  				count = peripheralNames.length;
    					//console.log(count);
    	  				return count;
    	  			}
    			}
    		}
    		catch(err) {
    
    		}
    	}
    	if (count == 0)
    	{
    		return -1;
    	}
        return (count);
    }
    
    
    function peripheralNames(peripheralType)
    {
    	let peripherals = system.deviceData.peripherals
        //console.log(peripherals);
    	let numberOfPeripherals = Object.keys(peripherals).length;
    	var names = [];
    
    	//console.log(numberOfPeripherals);
    
    	for (var peripheral in peripherals) {
    
    	  	try
    	  	{
    	  		var interfaces = peripherals[peripheral]["interfaces"];
                //console.log(interfaces);
    	  		for (var interfaceType in interfaces)
    	  		{
    	  			if (peripheralType == interfaceType)
    	  			{
    	  				names = interfaces[interfaceType].peripherals;
    	  				//console.log(names);
    	  				return names;
    	  			}
    			}
    		}
    		catch(err) {
    
    		}
    	}
        //console.log(names);
        return (names);
    }
    
    
    function CLB_isType1() {
        return ["F28004x"].includes(getDeviceName());
    }
    
    function CLB_isType2() {
        return ["F28002x", "F2838x", "F28003x"].includes(getDeviceName());
    }
    
    function CLB_isType1_Type2(){
        return (CLB_isType1() | CLB_isType2());
    }
    
    function SYSCLK_getMaxMHz()
    {
        var sysclk_max = {
            F2807x      : 120,
            F2837xS     : 200,
            F2837xD     : 200,
            F2838x      : 200,
            F28004x     : 100,
            F28002x     : 100,
            F28003x     : 120,
            F280013x    : 120,
            F280015x    : 120,
            F28P65x     : 200
        }
        return sysclk_max[getDeviceName()];
    }
    
    
    
    /*
     *  ======== typeMatches ========
     *  Check that HW signal type matches a specified array of types
     *
     *  Example: within a module's filterHardware(component) method:
     *      for (sig in component.signals) {
     *          let type = component.signals[sig].type;
     *          if (Common.typeMatches(type, ["PWM", "DOUT"])) {
     *              :
     *          }
     *      }
     *
     *  type      - a string or array of strings that are valid signal types
     *  nameArray - array of signal name types that must match one of the signal
     *              types named by type
     *
     *  Returns true iff nameArray contains at least one type name that's
     *          specified the type parameter.
     */
    function typeMatches(type, nameArray)
    {
        let options = {};
    
        if (type instanceof Array || typeof type == "object") {
            for (var i = 0; i < type.length; i++) {
                options[type[i]] = 1;
            }
        }
        else if (typeof type == "string" || type instanceof String) {
            options[type] = 1;
        }
    
        for (var i = 0; i < nameArray.length; i++) {
            let name = nameArray[i];
            if (name in options) {
                return (true);
            }
        }
    
        return (false);
    }
    
    function getDeviceTRM()
    {
        var deviceTRMLinks = {
            "F2807x":   "https://www.ti.com/lit/spruhm9",
            "F2837xS":  "https://www.ti.com/lit/spruhx5",
            "F2837xD":  "https://www.ti.com/lit/spruhm8",
            "F28004x":  "https://www.ti.com/lit/sprui33",
            "F2838x":   "https://www.ti.com/lit/spruii0",
            "F28002x":  "https://www.ti.com/lit/spruin7",
            "F28003x":  "https://www.ti.com/lit/spruiw9",
            "F280013x": "https://www.ti.com/lit/spruix1",
            "F280015x": "https://www.ti.com/lit/spruiy4"
        }
    
        var deviceTRMLink = deviceTRMLinks[getDeviceName()];
        if (deviceTRMLink)
        {
            return deviceTRMLink
        }
        else
        {
            return ""
        }
    }
    
    function getDeviceDatasheet()
    {
        var deviceDSLinks = {
            "F2807x":   "https://www.ti.com/lit/gpn/tms320f28075",
            "F2837xS":  "https://www.ti.com/lit/gpn/tms320f28377s",
            "F2837xD":  "https://www.ti.com/lit/gpn/tms320f28379d",
            "F28004x":  "https://www.ti.com/lit/gpn/tms320f280049",
            "F2838x":   "https://www.ti.com/lit/gpn/tms320f28388d",
            "F28002x":  "https://www.ti.com/lit/gpn/tms320f280025c",
            "F28003x":  "https://www.ti.com/lit/gpn/tms320f280039c",
            "F280013x": "https://www.ti.com/lit/gpn/tms320f2800137",
            "F280015x": "https://www.ti.com/lit/gpn/tms320f2800157"
        }
    
        var deviceDSLink = deviceDSLinks[getDeviceName()];
        if (deviceDSLink)
        {
            return deviceDSLink
        }
        else
        {
            return ""
        }
    }
    
    function getCollateralFindabilityList(peripheral)
    {
        var res = "";
        //*********************************************************************
        // GETTING STARTED WITH SYSCONFIG
        //*********************************************************************
        res += "**"
        res += "Sysconfig Resources"
        res += "**\n"
        res += "*   [C2000 SysConfig - Step by Step Guide on How to use C2000 SysConfig](https://www.ti.com/lit/spracx3)\n"
        res += "*   [C2000 SysConfig - Speed Up Development With C2000 Real-Time MCUs Using SysConfig](https://www.ti.com/lit/spry341)\n"
        res += "\n"
    
        var deviceGPN = getDeviceName();
        var cdata = Collateral.getCollateralData();
        // console.log(cdata[peripheral]);
        for (var i=0; i < cdata[peripheral].length; i++)
        {
            //*********************************************************************
            // CATEGORY TITLE
            //*********************************************************************
            var category_dict = cdata[peripheral][i];
            // console.log(category_dict['category_displayName'])
    
            // first check if the category is used by this device at all (not filtered out from this device)
            var category_used = false;
            for (var j=0; j < category_dict['content'].length; j++)
            {
                var content_dict = category_dict['content'][j]
                if (    ('devices' in content_dict && content_dict['devices'].includes(deviceGPN)) ||
                        !('devices' in content_dict)
                )
                {
                    category_used = true;
    
                    // break out of loop on the first occurrence of a collateral that is used for this device
                    break;
                }
            }
    
            // now if it was used, go ahead and add the category title
            if (category_used)
            {
                res += "\n# **" +
                        category_dict['category_displayName'] +
                        "**\n"
            }
    
            //*********************************************************************
            // COLLATERAL LINKS WITHIN CATEGORY
            //*********************************************************************
            // add each content item that applies
            for (var j=0; j < category_dict['content'].length; j++)
            {
                var content_dict = category_dict['content'][j]
                if (    ('devices' in content_dict && content_dict['devices'].includes(deviceGPN)) ||
                        !('devices' in content_dict)
                )
                {
                    // italicize if this is an App Note
                    if ( 'appNote' in content_dict )
                    {
                        res += "*   *[" +
                                content_dict['name'] +
                                "](" +
                                content_dict['url'] +
                                ")*"
                    }
                    // don't italicize if not an app note
                    else
                    {
                        res += "*   [" +
                                content_dict['name'] +
                                "](" +
                                content_dict['url'] +
                                ")"
                    }
    
                    // add a (Video) tag if this is a video
                    if ('video' in content_dict)
                    {
                        res += " (Video)"
                    }
    
                    // now add a newline to finish up the normal bullet
                    res += "\n"
    
                    //*********************************************************************
                    // EXTRA TEXT FOR THIS COLLATERAL LINK
                    //*********************************************************************
                    // add the "Extra Text" as a sub-bullet if it exits
                    if ('description' in content_dict)
                    {
                        res += "    *   " +
                                content_dict['description'] +
                                "\n"
                    }
                }
            }
    
        }
    
        //*********************************************************************
        // DEVICE TRM
        //*********************************************************************
        // finally, add the device TRM to the bottom of the list
        // res += "---\n"
        res += "\n# ***"
        res += "["+deviceGPN+" Technical Reference Manual](" + getDeviceTRM() + ")"
        res += "***\n"
    
    
        return res
    }
    

    Remember that once you do this you are basically half updating you C2000WARE. I hope it doesn't cause any other module to not work. I cant think of the changes affecting anything.

    Then you have one last step:

    In the inputxbar_input.js file, UNCOMMENT the line 167:

  • Thank you for the files.

    I did the mods but get the following error when I open the .syscfg file in CCS:

    Unable to render selection
    TypeError: Pinmux.getGPIOFromDevicePinName is not a function
    
        at Object.getValue (C:\ti\c2000\C2000Ware_4_02_00_00\driverlib\.meta\inputxbar_input.js:101:56)
        at cb (webpack:///src/pinmux/services/objectManagers/configurable.ts:122:24)
        at Object.withDeprecatedAccess (webpack:///src/pinmux/services/deprecatedAccessGuard.ts:14:10)
        at Object.disableScriptingForCallback (webpack:///src/pinmux/services/scripting/scriptingGuard.ts:14:10)
        at expensiveFunction (webpack:///src/pinmux/services/objectManagers/configurable.ts:121:5)
        at getValue (webpack:///src/pinmux/services/utils.ts:440:17)
        at B.value (webpack:///src/pinmux/services/objectManagers/configurable.ts:127:16)
        at B.getValue (webpack:///src/pinmux/services/objectManagers/member.ts:317:15)
        at o.render (webpack:///src/pinmux/services/objectManagers/ui/configurables/textConfigurable.tsx:15:16)
        at Ua (webpack:///node_modules/react-dom/cjs/react-dom.production.min.js:187:188)

    I guess I'm missing a modified pinmux.js.

  • Yes! My mistake. I am sending it to you now!

  • Here is the filehttps://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/171/pinmux.js

  • Thank you but I have another error:

    Error: Exception occurred calling addInstance()
    
        at Proxy.<anonymous> (webpack:///src/pinmux/services/scripting/scriptingGuard.ts:34:10)
        at scriptFunc (W:\Build\OBC_CPU1\OBC.syscfg:15:30)
        at cb (webpack:///src/pinmux/services/scripting/runScript.ts:94:27)
        at Object.withDeprecatedAccess (webpack:///src/pinmux/services/deprecatedAccessGuard.ts:14:10)
        at Object.runAsUserScript (webpack:///src/pinmux/services/scripting/scriptingGuard.ts:49:3)
        at iteratee (webpack:///src/pinmux/services/scripting/runScript.ts:94:5)
        at baseEach (webpack:///node_modules/lodash/lodash.js:530:11)
        at Function.each (webpack:///node_modules/lodash/lodash.js:9409:52)
        at iteratee (webpack:///src/pinmux/services/scripting/runScript.ts:92:6)
        at st (webpack:///node_modules/lodash/lodash.js:530:11)
    Caused by: TypeError: PinmuxMigrations.interfaceInclusiveRename is not a function
        at Object.getGpioQualificationModInstDefinitions (C:\ti\c2000\C2000Ware_4_02_00_00\driverlib\.meta\pinmux.js:15:53)
        at func (C:\ti\c2000\C2000Ware_4_02_00_00\driverlib\.meta\can.js:347:33)
        at cb (webpack:///src/pinmux/services/objectManagers/moduleRequirements/requirements.ts:26:6)
        at Object.guardCallbackAccess (webpack:///src/pinmux/services/moduleAccessGuard.ts:44:10)
        at h.resolveRequirements (webpack:///src/pinmux/services/objectManagers/moduleRequirements/requirements.ts:25:5)
        at _.resolveRequirements (webpack:///src/pinmux/services/objectManagers/moduleInstance.ts:927:27)
        at _.initDynamicConfigurables (webpack:///src/pinmux/services/objectManagers/moduleInstance.ts:823:8)
        at Function.createInstanceImpl (webpack:///src/pinmux/services/objectManagers/moduleInstance.ts:134:11)
        at Function.createInstance (webpack:///src/pinmux/services/objectManagers/moduleInstance.ts:999:28)
        at webpack:///src/pinmux/services/instanceContainers/module.ts:184:66

  • Ah yeah there are a log of changes in those files and I didn't foresee them causing these errors.

    How about this, can you revert your Common.js and Pinmux.js back to the original one from C2000WARE 4.02, then I can send you a fully self contained inputxbar_input.js so we don't have to worry about any of these other dependencies?

  • Sure, I can do that. Thanks.

  • Okay let me package that up!

  • Here revert Pinmux.js and Common.js back and try to just have the inputxbar_input.js updated with this:

    let Common   = system.getScript("/driverlib/Common.js");
    let Pinmux   = system.getScript("/driverlib/pinmux.js");
    let InputXbar_DevSpecific  = system.getScript("/driverlib/inputxbar/inputxbar_deviceSpecific.js");
    
    let device_driverlib_peripheral = 
        system.getScript("/driverlib/device_driverlib_peripherals/" + 
            Common.getDeviceName().toLowerCase() + "_xbar.js");
    
    /* Intro splash on GUI */
    let longDescription = "The Input X-BAR is used to route signals from a GPIO to many different" +
                        " IP blocks such as the ADC(s), eCAP(s), ePWM(s), and external interrupts";
    
    var inputXbarCount = 16
    if (["F2837xD", "F2838xS", "F2807x"].includes(Common.getDeviceName()))
    {
        inputXbarCount = 14
    }
    
    
    /* Array of Input X-bar configurables that are common across device families */
    var config = [
    
    ];
    
    var gpios = Common.getGPIOs();
    var aios = Common.getAIOs();
    var inputxbarGPIOOptions = InputXbar_DevSpecific.getExtraInputOptions();
    for (var gpioIndex = 0; gpioIndex < gpios.length; gpioIndex++)
    {
        inputxbarGPIOOptions.push({name: gpios[gpioIndex]});
    }
    for (var aioIndex = 0; aioIndex < aios.length; aioIndex++)
    {
        inputxbarGPIOOptions.push({name: aios[aioIndex]});
    }
    
    var inputNumOptions = []
    for (var inputNum of device_driverlib_peripheral.XBAR_InputNum)
    {
        inputNumOptions.push({
            name: inputNum.name
        })
    }
    
    var inputxbarINPUTConfig = {
        name        : "inputxbarInput",
        displayName : "INPUT",
        description : 'The INPUT number for Input X-Bar',
        hidden      : false,
        default     : inputNumOptions[0].name,
        options     : inputNumOptions
    }
    
    var inputxbarGPIOConfig = {
        name        : "inputxbarGpio",
        displayName : "INPUT Source",
        description : 'GPIO for this Input X-Bar',
        hidden      : false,
        default     : inputxbarGPIOOptions[0].name,
        options     : inputxbarGPIOOptions
    }
    
    function getGPIOFromDevicePinName(devicePinName)
    {
        var gpioNames = []
        var isAgpioPin = false
        var gpioName = devicePinName;
        if (!gpioName.startsWith("GPIO"))
        { 
            isAgpioPin = true 
        }
        gpioName = gpioName.substring(gpioName.indexOf("GPIO"))
        if ((gpioName.match(/GPIO/g) || []).length > 1)
        { 
            //
            // Double bonded
            //
            var gpiosOnThisPin = gpioName.split("GPIO");
            gpiosOnThisPin.splice(0, 1)
            for (var gpioOnThisPin of gpiosOnThisPin)
            {
                var gpioNumberOnThisPin = Common.gpioNameToNumber(gpioOnThisPin);
                gpioNames.push("GPIO" + gpioNumberOnThisPin)
            }
            return gpioNames
            
        }
        gpioName = gpioName.substring(4); // determine which GPIO
        var gpioNumber = Common.gpioNameToNumber(gpioName);
        gpioNames.push("GPIO" + gpioNumber)
        return gpioNames
    }
    
    
    var inputxbarSelectedSourceConfig = {
        name        : "inputxbarSelectedSource",
        displayName : "Selected Source Of GPIO",
        description : 'Selected GPIO is connected to this signal in the application',
        hidden      : false,
        default     : "",
        getValue    : (inst) => {
            let modNames = Object.keys(system.modules).sort();
            for (var modName of modNames)
            {
                var mod = system.modules[modName]
                var pinmuxRequirementsFunc = mod.pinmuxRequirements;
                if (pinmuxRequirementsFunc)
                {
                    for (var modInstance of mod.$instances)
                    {
                        var pinmuxRequirements = pinmuxRequirementsFunc(modInstance);
                        //console.log(pinmuxRequirements)
                        for (var pinmuxReq of pinmuxRequirements)
                        {
                            var pinmuxReqName = pinmuxReq.name;
                            //console.log(pinmuxReqName)
                            if (pinmuxReq.resources)
                            {
                                //
                                // Normal Peripheral Other than GPIO
                                //
                                var peripheralName = modInstance[pinmuxReqName].$solution.peripheralName
                                //console.log(peripheralName)
                                for (var pinmuxReqInterface of pinmuxReq.resources)
                                {
                                    var pinmuxReqInterfaceName = pinmuxReqInterface.name
                                    var devicePinName = modInstance[pinmuxReqName][pinmuxReqInterfaceName].$solution.devicePinName
                                    var peripheralPinName = modInstance[pinmuxReqName][pinmuxReqInterfaceName].$solution.peripheralPinName
                                    //console.log(peripheralPinName)
                                    //console.log(devicePinName)
    
                                    var gpioNames = getGPIOFromDevicePinName(devicePinName)
                                    //console.log(gpioNames)
    
                                    if (gpioNames.includes(inst.inputxbarGpio))
                                    {
                                        //console.log("Found: " + modInstance.$name + " = " + peripheralPinName)
                                        return (modInstance.$name + " = " + peripheralPinName)
                                    }
                                }
                            }
                            else
                            {
                                //
                                // GPIO
                                //
                                var peripheralName = modInstance[pinmuxReqName].$solution.peripheralName
                                var devicePinName = modInstance[pinmuxReqName].$solution.devicePinName
                                var peripheralPinName = modInstance[pinmuxReqName].$solution.peripheralPinName
                                //console.log(peripheralName)
                                //console.log(peripheralPinName)
                                //console.log(devicePinName)
                                if (devicePinName)
                                {
                                    //
                                    // Normal GPIO, single bonded AGPIO
                                    //
                                    var gpioNames = getGPIOFromDevicePinName(devicePinName)
                                    //console.log(gpioNames)
                                    if (gpioNames.includes(inst.inputxbarGpio))
                                    {
                                        //console.log("Found: " + modInstance.$name + " = " + peripheralPinName)
                                        return (modInstance.$name + " = " + peripheralPinName)
                                    }
                                }
                                else
                                {
                                    //
                                    // Double bonded AGPIO and AIOs
                                    //
                                    if (peripheralName == inst.inputxbarGpio)
                                    {
                                        //console.log("Found: " + modInstance.$name + " = " + peripheralName)
                                        return (modInstance.$name + " = " + peripheralName)
                                    }
                                }
                            }
                        }
                        //console.log(pinmuxRequirementsFunc(modInstance))
                    }
                }
            }
            //console.log(system)
            return "This source is not used by any module"
        }
    }
    
    var inputxbarLOCKConfig = {
        name        : "inputxbarLock",
        displayName : "INPUT Lock",
        description : 'Lock this Input X-Bar',
        hidden      : false,
        default     : false
    }
    
    config.push(inputxbarINPUTConfig);
    config.push(inputxbarGPIOConfig);
    config.push(inputxbarSelectedSourceConfig);
    config.push(inputxbarLOCKConfig);
    
    function onValidate(inst, validation)
    {
        var usedInsts = [];
        for (var instance_index in inst.$module.$instances)
        {
            var instance_obj = inst.$module.$instances[instance_index];
            usedInsts.push(instance_obj.inputxbarInput);
        }
        
        var duplicatesResult = Common.findDuplicates(usedInsts)
        
        if (duplicatesResult.duplicates.length != 0)
        {
            var allDuplicates = "";
            for (var duplicateNamesIndex in duplicatesResult.duplicates)
            {
                allDuplicates = allDuplicates + Common.stringOrEmpty(allDuplicates, ", ")
                                + duplicatesResult.duplicates[duplicateNamesIndex];
            }
            validation.logError(
                "This instance is already in use! Duplicates: " + allDuplicates,
                inst, "inputxbarInput");
        }
    }
    
    /*
     *  ======== filterHardware ========
     *  Control RX, TX Pin usage by the user specified dataDirection.
     *
     *  param component - hardware object describing signals and
     *                     resources they're attached to
     *
     *  returns Boolean indicating whether or not to allow the component to
     *           be assigned to an instance's $hardware config
     */
    function filterHardware(component)
    {
        return (Common.typeMatches(component.type, ["INPUTXBAR"]));
    }
    
    if (Common.onlyPinmux())
    {
        //config = [];
    }
    var inputxbarModule = {
        peripheralName: "INPUTXBAR",
        displayName: "INPUTXBAR INPUT",
        maxInstances: inputXbarCount,
        defaultInstanceName: "myINPUTXBARINPUT",
        description: "Input X-bar",
        filterHardware : filterHardware,
        config: config,
        validate  :  onValidate,
        templates: {
            boardc : "/driverlib/inputxbar/inputxbar_input.board.c.xdt",
            boardh : "/driverlib/inputxbar/inputxbar_input.board.h.xdt"
        },
        //pinmuxRequirements    : Pinmux.inputxbarPinmuxRequirements
    };
    
    
    if (inputxbarModule.maxInstances <= 0)
    {
        delete inputxbarModule.pinmuxRequirements;
    }
    
    
    exports = inputxbarModule;
    

  • That seems to work well. Thank you very much!

  • Wonderful, if you can, try it out on F28004x, F2837xD, F2838x, F28002x, F28003x, F280013x to make sure it's not missing any specific logic. I tried to write the code with every device family in mind.

    For example on F280013x, our newest and LOWEST COST MCU ever, for small package, you have TWO GPIOs on the same pin, so I had to write the code to catch those scenarios.

    Let me know if you need anything else as well.

    Also please mark the thread responses I sent you with the "Green" verify answer button so the next customer can find their way to the answers.

  • Hi

    In the initial test above I was using F2837xD_337ZWT but the same does not seem to work for the F2837xD_100PTP:

    In any case, for the working BGA package (337ZWT) which I'm using for my project, I've realised that there's still a notional link missing to make this really worthwhile.

    For GPIO configuration I have to select by ball coordinate but in INPUTXBAR I have to select by GPIO number. That means I have to look up the ball coordinate in the datasheet, find the GPIO number and then select that number in the INPUTXBAR. Perhaps a way to improve this is for the GPIO configuration to say what GPIO number has been selected. For example:

  • That feature already exists I can show you how to enable that!

  • I requested to have that option enabled by default!

  • Due to thanksgiving holiday my responses may be delayed until monday!

  • Thanks Nima, Yes, that fixes the issue.

    In the situation where the user reverts "Device pin name" to OFF, intentionally or otherwise, the GPIO number becomes incorrect. Perhaps it is better to change the "GPIO" field description to "Pin"?

    Then it would say....

    "Device pin name" OFF:

    Pin    3

    "Device pin name" ON:

    PIn    GPIO12/3

    Both of these are unambiguous.

  • That's a great point. I think thats an easy change. Let me see if I can try it.