Skip to content

Commit

Permalink
Merge branch 'bugfix/rmt_tx_synchronization_tests' into 'master'
Browse files Browse the repository at this point in the history
driver(RMT): Fix RMT TX multi channel test

See merge request espressif/esp-idf!22051
  • Loading branch information
Dazza0 committed Jan 19, 2023
2 parents 668e125 + 1834d8a commit ac1c550
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions components/driver/test_apps/rmt/main/test_rmt_tx.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -465,6 +465,12 @@ static void test_rmt_multi_channels_trans(size_t channel0_mem_block_symbols, siz
{
#define TEST_RMT_CHANS 2
#define TEST_LED_NUM 24
#define TEST_STOP_TIME_NO_SYNCHRO_DELTA 150
#if CONFIG_IDF_TARGET_ESP32C6
#define TEST_STOP_TIME_SYNCHRO_DELTA 400
#else
#define TEST_STOP_TIME_SYNCHRO_DELTA 10
#endif // CONFIG_IDF_TARGET_ESP32C6
rmt_tx_channel_config_t tx_channel_cfg = {
.clk_src = RMT_CLK_SRC_DEFAULT,
.resolution_hz = 10000000, // 10MHz, 1 tick = 0.1us (led strip needs a high resolution)
Expand Down Expand Up @@ -526,7 +532,7 @@ static void test_rmt_multi_channels_trans(size_t channel0_mem_block_symbols, siz
printf("\t%lld\r\n", record_stop_time[i]);
}
// without synchronization, there will be obvious time shift
TEST_ASSERT((record_stop_time[1] - record_stop_time[0]) < 100);
TEST_ASSERT_INT64_WITHIN(TEST_STOP_TIME_NO_SYNCHRO_DELTA, record_stop_time[0], record_stop_time[1]);

printf("install sync manager\r\n");
rmt_sync_manager_handle_t synchro = NULL;
Expand Down Expand Up @@ -556,7 +562,7 @@ static void test_rmt_multi_channels_trans(size_t channel0_mem_block_symbols, siz
}
// because of synchronization, the managed channels will stop at the same time
// but call of `esp_timer_get_time` won't happen at the same time, so there still be time drift, very small
TEST_ASSERT((record_stop_time[1] - record_stop_time[0]) < 10);
TEST_ASSERT_INT64_WITHIN(TEST_STOP_TIME_SYNCHRO_DELTA, record_stop_time[0], record_stop_time[1]);

printf("reset sync manager\r\n");
TEST_ESP_OK(rmt_sync_reset(synchro));
Expand All @@ -573,7 +579,7 @@ static void test_rmt_multi_channels_trans(size_t channel0_mem_block_symbols, siz
for (int i = 0; i < TEST_RMT_CHANS; i++) {
printf("\t%lld\r\n", record_stop_time[i]);
}
TEST_ASSERT((record_stop_time[1] - record_stop_time[0]) < 10);
TEST_ASSERT_INT64_WITHIN(TEST_STOP_TIME_SYNCHRO_DELTA, record_stop_time[0], record_stop_time[1]);

printf("delete sync manager\r\n");
TEST_ESP_OK(rmt_del_sync_manager(synchro));
Expand Down
2 changes: 2 additions & 0 deletions components/driver/test_apps/rmt/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
CONFIG_FREERTOS_HZ=1000
CONFIG_ESP_TASK_WDT=n
CONFIG_UNITY_ENABLE_64BIT=y
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096

0 comments on commit ac1c550

Please sign in to comment.