RMT resolution divider rounding error (IDFGH-14301) #15092
Labels
Resolution: NA
Issue resolution is unavailable
Status: Done
Issue is done internally
Type: Bug
bugs in IDF
Answers checklist.
IDF version.
v5.3.2
Espressif SoC revision.
ESP32
Operating System used.
Windows
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
Development Kit.
ESP32-Wroom
Power Supply used.
USB
What is the expected behavior?
I need very precise RMT output frequency, so I would like to configure the RMT with a resolution of 720721Hz (based on 80MHz APB clock)
=> this give a theorical divider of 110.999956
=> expected to choose the nearest divider (111) in order to minimize the resolution loos
What is the actual behavior?
The divider is not round to nearest, but truncated to int.
in my case, i get lot of loss !
727272Hz (+7kHz !) instead of 720720.7207Hz (-0.2793Hz)
Steps to reproduce.
rmt_tx_channel_config_t tLocTxChannelConfig = {
.clk_src = RMT_CLK_SRC_DEFAULT,
.gpio_num = xxx,
.mem_block_symbols = 64,
.resolution_hz =720721,
.trans_queue_depth = 10,
.flags.invert_out = false,
.flags.with_dma = false,
.flags.io_loop_back = true
};
ESP_LOGI(TAG, "Init RMT for %s (res=%i)", psInContext->cpsConfig->cpcName, (int)tLocTxChannelConfig.resolution_hz);
ESP_ERROR_CHECK(rmt_new_tx_channel(&tLocTxChannelConfig, &psInContext->tTxChannelHandle));
Debug Logs.
More Information.
suggestion to round to nearest integer:
or something like that: 🤢
uint32_t real_div= (uint32_t)(((float)group->resolution_hz/config->resolution_hz)+0.5)
The text was updated successfully, but these errors were encountered: