From 2d12a7dc442ec2ef7b453f97d57e1a729aaafe83 Mon Sep 17 00:00:00 2001 From: "gruvin@gmail.com" Date: Sun, 11 Nov 2012 08:48:50 +0000 Subject: [PATCH] [g9xv4] Tightened up DSM2_PPM latency by reverting previous band-aid fix for mixer timing problems, now fixed. Added/edited code comments some more. --- src/pulses_avr.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pulses_avr.cpp b/src/pulses_avr.cpp index 99671b1cf..dc058cb96 100644 --- a/src/pulses_avr.cpp +++ b/src/pulses_avr.cpp @@ -863,10 +863,14 @@ void setupPulses() default: // PPM and DSM2=SERIAL modes set_timer3_capture(); - TCCR1B = 0; // Stop counter + TCCR1B = 0; // Stop counter 1 TCNT1 = 0; // Must reset counter frist, to prevent possible immediate COMPA int. (sometimes). - OCR1A = 44000; // Next frame starts in 22ms -- DSM mode. PPM mode will adjust to the frame rate - // set in model SETUP menu, when setupPulsesPPM() is called, below. + OCR1A = 44000; // Next frame starts in 22ms -- DSM mode. + // This is arbitrary and for the first frame only. In fact, ... + // DSM2 mode will set frame timing again at each ISR(TIMER1_COMPC_vect) + // and + // PPM mode will dynamically adjust to the frame rate set in model SETUP menu, + // from within setupPulsesPPM(). #if defined(PCBGRUVIN9X) TIMSK1 &= ~0x2F; // All Timer1 interrupts off TIFR1 = 0x2F; @@ -1008,7 +1012,7 @@ ISR(TIMER1_COMPC_vect) // DSM2_PPM or PXX end of frame #if defined(DSM2_PPM) ICR1 = 41536 ; // next frame starts in 22ms 41536 = 2*(22000 - 14*11*8) if (OCR1C < 255) { - OCR1C = 39000; // delay setup pulses by 19.5ms to reduce system latency + OCR1C = 41000; // delay setup pulses by 20.5ms to reduce system latency } else { OCR1C = 200;