gusucode.com > target工具箱matlab源码程序 > target/extensions/processor/tic2000/utils/calcWatchdogParemeters.m

    function Time_period = calcWatchdogParemeters(OSCCLKInMHz, WatchdogclockStr, numBitsWatchdogCounter)
%CALCWATCHDOGPAREMETERS Summary of this function goes here
%   Detailed explanation goes here


OSCCLK = OSCCLKInMHz * 1e6; % MHz to Hz
     
dividers = getDividerValueFromString(WatchdogclockStr);
watchdog_freq = OSCCLK;
for i = 1:numel(dividers)
    watchdog_freq = watchdog_freq/dividers(i);
end

% The watchdog counter considered is 'numBitsWatchdogCounter' counter.  Hence the value 
% 2^(numBitsWatchdogCounter) is considered to calculate total time required to overflow the
% watchdog counter.
Time_period = (2^numBitsWatchdogCounter)/watchdog_freq;