From 86399ac53208b655ddb7a6cd8b1047e6d2a7a559 Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Tue, 16 Jul 2019 10:04:34 -0400 Subject: forward port of avg_error calc divide-by-zero fix from AVR-8A-B-P-QTKB repair --- error_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'error_utils.c') diff --git a/error_utils.c b/error_utils.c index cc08a3f..5edea83 100644 --- a/error_utils.c +++ b/error_utils.c @@ -913,7 +913,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) check_another_max_value (temp, &globals.Constraints.err_max_freq[i], ChannelStateToTest[i].frequency, HVPS_Current_Too_High, &report_error); } - if (globals.Flash.max_avg_power[i] > 0.0) { + if ((globals.Flash.max_avg_power[i] > 0.0) && (fabs(ChannelStateToTest[i].amplitude) > 0.0)) { temp = (globals.Flash.max_avg_power[i] * ChannelStateToTest[i].load_type) / (ChannelStateToTest[i].amplitude * ChannelStateToTest[i].amplitude * ChannelStateToTest[i].pw); check_another_max_value (temp, &globals.Constraints.err_max_freq[i], ChannelStateToTest[i].frequency, average_power_limit, &report_error); } @@ -977,7 +977,7 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) &globals.Constraints.err_max_pw[i], ChannelStateToTest[i].pw, HVPS_Current_Too_High, &report_error); } - if (globals.Flash.max_avg_power[i] > 0.0) { + if ((globals.Flash.max_avg_power[i] > 0.0) && (fabs(ChannelStateToTest[i].amplitude) > 0.0)) { check_another_max_value (globals.Flash.max_avg_power[i] * ChannelStateToTest[i].load_type / (ChannelStateToTest[i].amplitude * ChannelStateToTest[i].amplitude * ChannelStateToTest[i].frequency), &globals.Constraints.err_max_pw[i], ChannelStateToTest[i].pw, average_power_limit, &report_error); -- cgit