1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-26 09:45:21 +03:00

[gruvin9x] DSM2-PPM better timings

This commit is contained in:
bsongis 2012-11-09 10:00:28 +00:00
parent fa28b67db6
commit 7d63dbf226
3 changed files with 8 additions and 11 deletions

View file

@ -97,7 +97,7 @@ uint8_t unexpectedShutdown = 0;
uint16_t g_timeMainMax;
#if defined(PCBGRUVIN9X)
uint8_t g_timeMainLast;
uint8_t lastMixerDuration;
#endif
#if defined(AUDIO) && !defined(PCBSKY9X)
@ -3040,7 +3040,7 @@ ISR(TIMER5_COMPA_vect, ISR_NOBLOCK) // mixer interrupt
}
t0 = getTmr16KHz() - t0;
g_timeMainLast = t0 / 8;
lastMixerDuration = t0 / 8;
if (t0 > g_timeMainMax) g_timeMainMax = t0 ;
cli();

View file

@ -771,7 +771,7 @@ extern uint8_t g_tmr1Latency_max;
extern uint8_t g_tmr1Latency_min;
extern uint16_t g_timeMainMax;
#if defined(PCBGRUVIN9X)
extern uint8_t g_timeMainLast;
extern uint8_t lastMixerDuration;
#endif
#if defined(THRTRACE)

View file

@ -194,13 +194,6 @@ void setupPulsesPPM(uint8_t proto)
uint8_t p = (proto == PROTO_PPM16 ? 16 : 8) + (g_model.ppmNCH * 2); //Channels *2
uint16_t q = (g_model.ppmDelay*50+300)*2; // Stoplen *2
uint32_t rest = 22500u*2 - q; // Minimum Framelen=22.5ms
#if defined(PCBGRUVIN9X)
if (proto == PROTO_PPM) {
OCR5A = (uint16_t)0x7d * (45+g_model.ppmFrameLength-g_timeMainLast-2/*1ms*/);
TCNT5 = 0;
}
#endif
rest += (int32_t(g_model.ppmFrameLength))*1000;
for (uint8_t i=(proto==PROTO_PPM16) ? p-8 : 0; i<p; i++) {
@ -891,7 +884,7 @@ void setupPulses()
#ifdef DSM2
case PROTO_DSM2:
#if defined(PCBGRUVIN9X)
OCR5A = (uint16_t)0x7d * (40-g_timeMainLast-2/*1ms*/);
OCR5A = (uint16_t)0x7d * (44-lastMixerDuration-2/*1ms*/);
TCNT5 = 0;
#endif
sei();
@ -913,6 +906,10 @@ void setupPulses()
#endif
default:
#if defined(PCBGRUVIN9X)
OCR5A = (uint16_t)0x7d * (45+g_model.ppmFrameLength-lastMixerDuration-2/*1ms*/);
TCNT5 = 0;
#endif
// no sei here
setupPulsesPPM(PROTO_PPM);
// if PPM16, PPM16 pulses are set up automatically within the interrupts