Fix 1322

fixes #1322  Added checks in two places for on bit mask comparison to _stimulusThreshold because while loops need a little extra care to prevent endless loops...