Function to calculate a reasonable prescaler for PWM or interrupts at a specific frequency
function reasonableClockSelect extends .Modelica.Icons.Function; import SIunits = Modelica.Units.SI; import Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types; input SIunits.Frequency cpu, desired; input Real allowedError; input SIunits.Frequency prescalerConstants[Types.TimerPrescaler]; output Types.TimerPrescaler prescaler; end reasonableClockSelect;