Skip to content

Commit 4e2dad6

Browse files
committed
Merge branch 'bugfix/channel_resolution_calculation' into 'master'
fix(rmt): channel resolution divider rounding issue Closes IDFGH-14301 See merge request espressif/esp-idf!35989
2 parents 01b1191 + 9b3ea0c commit 4e2dad6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

components/esp_driver_rmt/src/rmt_rx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ esp_err_t rmt_new_rx_channel(const rmt_rx_channel_config_t *config, rmt_channel_
278278

279279
// select the clock source
280280
ESP_GOTO_ON_ERROR(rmt_select_periph_clock(&rx_channel->base, config->clk_src), err, TAG, "set group clock failed");
281-
// set channel clock resolution
282-
uint32_t real_div = group->resolution_hz / config->resolution_hz;
281+
// set channel clock resolution, find the divider to get the closest resolution
282+
uint32_t real_div = (group->resolution_hz + config->resolution_hz / 2) / config->resolution_hz;
283283
rmt_ll_rx_set_channel_clock_div(hal->regs, channel_id, real_div);
284284
// resolution loss due to division, calculate the real resolution
285285
rx_channel->base.resolution_hz = group->resolution_hz / real_div;

components/esp_driver_rmt/src/rmt_tx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ esp_err_t rmt_new_tx_channel(const rmt_tx_channel_config_t *config, rmt_channel_
333333
#endif
334334
// select the clock source
335335
ESP_GOTO_ON_ERROR(rmt_select_periph_clock(&tx_channel->base, config->clk_src), err, TAG, "set group clock failed");
336-
// set channel clock resolution
337-
uint32_t real_div = group->resolution_hz / config->resolution_hz;
336+
// set channel clock resolution, find the divider to get the closest resolution
337+
uint32_t real_div = (group->resolution_hz + config->resolution_hz / 2) / config->resolution_hz;
338338
rmt_ll_tx_set_channel_clock_div(hal->regs, channel_id, real_div);
339339
// resolution lost due to division, calculate the real resolution
340340
tx_channel->base.resolution_hz = group->resolution_hz / real_div;

0 commit comments

Comments
 (0)