From a754ad4f47bf60dea5ef84342a0043b9871f222b Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Sun, 1 Jul 2018 18:08:46 -0400 Subject: [PATCH] Change TASK_RX frequancy from 50hz (20ms) to 33hz (30ms) Work around to better handle RX protocols that have frame intervals >= 20ms. Otherwise the task would run at the end of the task interval causing slower protocols to run again after the remaining delay. This interferes with rc interpolation and also the frame rate detection in rc smoothing. --- src/main/fc/fc_rc.c | 1 - src/main/fc/fc_tasks.c | 4 ++-- src/main/rx/rx.c | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/fc/fc_rc.c b/src/main/fc/fc_rc.c index 3d095201ee..83c8c73716 100644 --- a/src/main/fc/fc_rc.c +++ b/src/main/fc/fc_rc.c @@ -486,7 +486,6 @@ FAST_CODE uint8_t processRcSmoothingFilter(void) } } else { // we have either stopped receiving rx samples (failsafe?) or the sample time is unreasonable so reset the accumulation - validRxFrameTimeMs = 0; rcSmoothingResetAccumulation(&rcSmoothingData); } } diff --git a/src/main/fc/fc_tasks.c b/src/main/fc/fc_tasks.c index 705882752a..fef1bd0c55 100644 --- a/src/main/fc/fc_tasks.c +++ b/src/main/fc/fc_tasks.c @@ -177,7 +177,7 @@ static void taskUpdateRxMain(timeUs_t currentTimeUs) } static timeUs_t lastRxTimeUs; - currentRxRefreshRate = constrain(currentTimeUs - lastRxTimeUs, 1000, 20000); + currentRxRefreshRate = constrain(currentTimeUs - lastRxTimeUs, 1000, 30000); lastRxTimeUs = currentTimeUs; isRXDataNew = true; @@ -459,7 +459,7 @@ cfTask_t cfTasks[TASK_COUNT] = { .taskName = "RX", .checkFunc = rxUpdateCheck, .taskFunc = taskUpdateRxMain, - .desiredPeriod = TASK_PERIOD_HZ(50), // If event-based scheduling doesn't work, fallback to periodic scheduling + .desiredPeriod = TASK_PERIOD_HZ(33), // If event-based scheduling doesn't work, fallback to periodic scheduling .staticPriority = TASK_PRIORITY_HIGH, }, diff --git a/src/main/rx/rx.c b/src/main/rx/rx.c index f565249d84..347881a54c 100644 --- a/src/main/rx/rx.c +++ b/src/main/rx/rx.c @@ -102,6 +102,7 @@ uint32_t rcInvalidPulsPeriod[MAX_SUPPORTED_RC_CHANNEL_COUNT]; #define PPM_AND_PWM_SAMPLE_COUNT 3 #define DELAY_50_HZ (1000000 / 50) +#define DELAY_33_HZ (1000000 / 33) #define DELAY_10_HZ (1000000 / 10) #define DELAY_5_HZ (1000000 / 5) #define SKIP_RC_ON_SUSPEND_PERIOD 1500000 // 1.5 second period in usec (call frequency independent) @@ -542,7 +543,7 @@ bool calculateRxChannelsAndUpdateFailsafe(timeUs_t currentTimeUs) } rxDataProcessingRequired = false; - rxNextUpdateAtUs = currentTimeUs + DELAY_50_HZ; + rxNextUpdateAtUs = currentTimeUs + DELAY_33_HZ; // only proceed when no more samples to skip and suspend period is over if (skipRxSamples) {