diff --git a/src/protocols/ppm_arm.cpp b/src/protocols/ppm_arm.cpp index 17b70c033..86e1973fe 100644 --- a/src/protocols/ppm_arm.cpp +++ b/src/protocols/ppm_arm.cpp @@ -65,14 +65,15 @@ void setupPulsesPPM(unsigned int port) // Don't enable interru #endif uint16_t * ptr = ppmStream[port]; - uint32_t rest = 22500u * 2; //Minimum Framelen=22.5 ms + int32_t rest = 22500u * 2; rest += (int32_t(g_model.moduleData[port].ppmFrameLength)) * 1000; for (uint32_t i=firstCh; i 65535) ? 65535 : rest; + if (rest > 65535) rest = 65535; /* prevents overflows */ + if (rest < 9000) rest = 9000; /* avoids that CCR2 is bigger than ARR which would cause reboot */ *ptr = rest; *(ptr + 1) = 0;