function time_period_seconds = calcWatchdogTimePeriod(oscclkinMHz, dividers)
%CALCWATCHDOGTIMEPERIOD Calculates the time required to overflow the
%wathdog timer.  The formula to calculate is
% Time_period = OSCCLK/512/DIVSEL
%   where DIVSEL = 2^(0, 1, 2, 3, 4, 5, 6)

% Copyright 2012 Mathworks, Inc

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

% The watchdog counter considered is 8-bit counter.  Hence the value 2^8 =
% 256 is considered to calculate total time required to overflow the
% watchdog counter.
time_period_seconds = 256/watchdog_freq;
