gusucode.com > target工具箱matlab源码程序 > target/extensions/processor/tic2000/utils/calcCpuClockSpeed.m
function [cpu_clock_speed, lspclk, hspclk] = calcCpuClockSpeed(osc_freq, pllcr, clkin_div, lspclk_div, hspclk_div) % Get the numeric value if ischar(osc_freq) osc_freq = str2double(osc_freq); end % Get the numeric value if ischar(pllcr) pllcr = str2double(pllcr); end % Get the numeric value if ischar(clkin_div) clkin_div = str2double(clkin_div); end % Get the numeric value if ischar(lspclk_div) lspclk_div = str2double(lspclk_div); end % Get the numeric value if ischar(hspclk_div) hspclk_div = str2double(hspclk_div); end % The pll is bypasses. Under this case oscillator clock is used if pllcr == 0 pllcr = pllcr + 1; end % CPU Clock alculation if clkin_div ~= 0 cpu_clock_speed = (osc_freq * pllcr) / clkin_div; else cpu_clock_speed = (osc_freq * pllcr); end % LSPCLK if lspclk_div ~= 0 lspclk = cpu_clock_speed / lspclk_div; else lspclk = cpu_clock_speed; end % HSPCLK if hspclk_div ~= 0 hspclk = cpu_clock_speed / hspclk_div; else hspclk = cpu_clock_speed; end