mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-01 02:21:46 +02:00
Check freq != 0 in PWMSpindle to prevent div-by-0 crashes
This commit is contained in:
@@ -225,6 +225,9 @@ namespace Spindles {
|
||||
*/
|
||||
uint8_t PWM::calc_pwm_precision(uint32_t freq) {
|
||||
uint8_t precision = 0;
|
||||
if (freq == 0) {
|
||||
return precision;
|
||||
}
|
||||
|
||||
// increase the precision (bits) until it exceeds allow by frequency the max or is 16
|
||||
while ((1 << precision) < (uint32_t)(80000000 / freq) && precision <= 16) {
|
||||
|
Reference in New Issue
Block a user