Skip to content

Commit

Permalink
slave module runs slightly above its requested rate
Browse files Browse the repository at this point in the history
  • Loading branch information
mha1 committed Aug 5, 2023
1 parent 22d799f commit 1e9ac9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion radio/src/mixer_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ uint16_t getMixerSchedulerPeriod()
if(module == synced_module)
sched.divider = 1;
else
sched.divider = ((sched.period - 1) / sync_period) + 1;
sched.divider = sched.period / sync_period;
}

_syncedModule = synced_module;
Expand Down
12 changes: 6 additions & 6 deletions radio/src/tests/mixer_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ TEST(MixerScheduler, MultiModules)
mixerSchedulerSetPeriod(EXTERNAL_MODULE, 2000);

EXPECT_EQ(getMixerSchedulerPeriod(), 2000);
EXPECT_EQ(getMixerSchedulerRealPeriod(INTERNAL_MODULE), 8000);
EXPECT_EQ(getMixerSchedulerRealPeriod(INTERNAL_MODULE), 6000);
EXPECT_EQ(getMixerSchedulerRealPeriod(EXTERNAL_MODULE), 2000);
EXPECT_EQ(getMixerSchedulerDivider(INTERNAL_MODULE), 4);
EXPECT_EQ(getMixerSchedulerDivider(INTERNAL_MODULE), 3);
EXPECT_EQ(getMixerSchedulerDivider(EXTERNAL_MODULE), 1);

// internal module 143Hz
Expand All @@ -50,9 +50,9 @@ TEST(MixerScheduler, MultiModules)
mixerSchedulerSetPeriod(EXTERNAL_MODULE, 3003);

EXPECT_EQ(getMixerSchedulerPeriod(), 3003);
EXPECT_EQ(getMixerSchedulerRealPeriod(INTERNAL_MODULE), 9009);
EXPECT_EQ(getMixerSchedulerRealPeriod(INTERNAL_MODULE), 6006);
EXPECT_EQ(getMixerSchedulerRealPeriod(EXTERNAL_MODULE), 3003);
EXPECT_EQ(getMixerSchedulerDivider(INTERNAL_MODULE), 3);
EXPECT_EQ(getMixerSchedulerDivider(INTERNAL_MODULE), 2);
EXPECT_EQ(getMixerSchedulerDivider(EXTERNAL_MODULE), 1);


Expand All @@ -63,7 +63,7 @@ TEST(MixerScheduler, MultiModules)

EXPECT_EQ(getMixerSchedulerPeriod(), 7000);
EXPECT_EQ(getMixerSchedulerRealPeriod(INTERNAL_MODULE), 7000);
EXPECT_EQ(getMixerSchedulerRealPeriod(EXTERNAL_MODULE), 14000);
EXPECT_EQ(getMixerSchedulerRealPeriod(EXTERNAL_MODULE), 7000);
EXPECT_EQ(getMixerSchedulerDivider(INTERNAL_MODULE), 1);
EXPECT_EQ(getMixerSchedulerDivider(EXTERNAL_MODULE), 2);
EXPECT_EQ(getMixerSchedulerDivider(EXTERNAL_MODULE), 1);
}

0 comments on commit 1e9ac9f

Please sign in to comment.