diff --git a/libraries/AP_HAL_AVR/RCOutput_APM2.cpp b/libraries/AP_HAL_AVR/RCOutput_APM2.cpp index fdf5106f25c6376e40843f6f9c6036b23b05b7eb..ab25eba617351ecbc01a99e1e7f6fc67ee56049d 100644 --- a/libraries/AP_HAL_AVR/RCOutput_APM2.cpp +++ b/libraries/AP_HAL_AVR/RCOutput_APM2.cpp @@ -153,8 +153,20 @@ void APM2RCOutput::write(uint8_t ch, uint16_t period_us) { switch(ch) { case 0: OCR1B=pwm; break; // out1 - case 1: OCR1A=pwm; break; // out2 - case 2: OCR4C=pwm; break; // out3 + case 1: { + //OCR1A=pwm; + break; // out2 + } + case 2: { + if (period_us > 1500) { + OCR4C=constrain_period((uint16_t)(period_us)) << 1; + OCR1A=constrain_period((uint16_t)(1000)) << 1; + } else { + OCR4C=constrain_period((uint16_t)(1500 - period_us + 1500)) << 1; + OCR1A=constrain_period((uint16_t)(2000)) << 1; + } + break; // out3 + } case 3: OCR4B=pwm; break; // out4 case 4: OCR4A=pwm; break; // out5 case 5: OCR3C=pwm; break; // out6