function ret = clockParameterDefaultValue(hObj, param)
%CLOCKPARAMETERDEFAULTVALUE Select the ePWM clock divider values.

% Copyright 2018-2023 The MathWorks, Inc.

ret = '';
cs = hObj.getConfigSet;
if codertarget.target.isCoderTarget(cs)
    targetHardware = codertarget.targethardware.getTargetHardware(cs);
    if isequal(targetHardware.SubFamily, '2837xD') || isequal(targetHardware.SubFamily, '2838x') || isequal(targetHardware.SubFamily, '28p65x')
        data = codertarget.data.getData(cs);
        switch param
            case 'ClosestCpuClock'
                if isfield(data, 'Clocking')
                    clockingData = codertarget.data.getParameterValue(cs, 'Clocking');
                    clockingData.ClosestCpuClock1 = clockingData.ClosestCpuClock;
                    codertarget.data.setParameterValue(cs, 'Clocking', clockingData);
                    ret = clockingData.ClosestCpuClock;
                else %default
                    ret = '200';
                end
            case 'LspclkDiv'
                if isfield(data, 'Clocking')
                    clockingData = codertarget.data.getParameterValue(cs, 'Clocking');
                    clockingData.LspclkDiv1 = clockingData.LspclkDiv;
                    codertarget.data.setParameterValue(cs, 'Clocking', clockingData);
                    ret = clockingData.LspclkDiv;
                else
                    ret = 'SYSCLKOUT/1';
                end
            case 'ePWM'
                if isfield(data, 'ePWM')
                    ePWMData = codertarget.data.getParameterValue(cs, 'ePWM');
                    if isfield(ePWMData, 'ClockDiv')
                        ePWMData.ClockDiv1 = ePWMData.ClockDiv;
                        codertarget.data.setParameterValue(cs, 'ePWM', ePWMData);
                        ret = ePWMData.ClockDiv;
                    else
                        ret = 'SYSCLKOUT/2';
                    end
                else
                    ret = 'SYSCLKOUT/2';
                end
            case 'CMCLKVAL'
                if isfield(data, 'Clocking')
                    clockingData = codertarget.data.getParameterValue(cs, 'Clocking');
                    clockingData.CMCLKVAL = (str2double(clockingData.ClosestCpuClock)*str2double(clockingData.DIVSEL))/str2double(clockingData.CMCLKDIV);
                    codertarget.data.setParameterValue(cs, 'Clocking', clockingData);
                    ret = clockingData.CMCLKVAL;
                else %default
                    ret = '100';
                end  
            case 'cpuClockRateMHz'
                if isfield(data, 'Clocking')
                    clockingData = codertarget.data.getParameterValue(cs, 'Clocking');
                    ret = clockingData.cpuClockRateMHz;
                else %default
                    ret = '100';
                end      
        end
    end
end
end