Skip to content

Commit

Permalink
Update CoreSTM32HalBasicTimer_test.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Mar 13, 2024
1 parent 844a3c5 commit 0af3549
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/CoreDAC/tests/CoreSTM32HalBasicTimer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ TEST_F(CoreSTM32HalBasicTimerTest, initializeConfig)
{
auto timer_handle = basic_timer.getHandle();

auto CK_INT = 54'000'000;
auto default_sample_rate = 44'100;
auto divider = CK_INT / default_sample_rate;
auto CK_INT = float(108'000'000.0);
auto default_sample_rate = float(44'100.0);
auto divider = std::round(CK_INT / default_sample_rate);

// The prescaler can divide the counter clock frequency by any factor between 1 and 65536, see 28.3.1 of RM
auto prescaler = timer_handle.Init.Prescaler;
Expand All @@ -139,7 +139,7 @@ TEST_F(CoreSTM32HalBasicTimerTest, initializeConfig)

// To fit required frequency (default sample rate), multiplying prescaler and auto-reload value must give
// approximately the divider
EXPECT_NEAR(prescaler * auto_reload_value, divider, 50);
EXPECT_NEAR(prescaler * auto_reload_value, divider, 1);

// Disable shadow write
EXPECT_EQ(timer_handle.Init.AutoReloadPreload, TIM_AUTORELOAD_PRELOAD_DISABLE);
Expand Down

0 comments on commit 0af3549

Please sign in to comment.