Skip to content

Commit fcac731

Browse files
authored
Merge pull request #9051 from tannewt/fix_h2
Fix RMT clock speed on H2
2 parents 636b9df + d34af65 commit fcac731

File tree

1 file changed

+7
-2
lines changed
  • ports/espressif/common-hal/neopixel_write

1 file changed

+7
-2
lines changed

ports/espressif/common-hal/neopixel_write/__init__.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
#include "shared-bindings/neopixel_write/__init__.h"
4444

45+
#include "esp_clk_tree.h"
4546
#include "py/mphal.h"
4647
#include "py/runtime.h"
4748

@@ -61,10 +62,14 @@ static uint64_t next_start_raw_ticks = 0;
6162

6263
void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, uint8_t *pixels, uint32_t numBytes) {
6364
// Reserve channel
65+
uint32_t clock_speed;
66+
esp_clk_tree_src_get_freq_hz(RMT_CLK_SRC_DEFAULT,
67+
ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED,
68+
&clock_speed);
6469
rmt_tx_channel_config_t config = {
6570
.gpio_num = digitalinout->pin->number,
6671
.clk_src = RMT_CLK_SRC_DEFAULT,
67-
.resolution_hz = 40000000,
72+
.resolution_hz = clock_speed,
6873
.trans_queue_depth = 1,
6974
};
7075

@@ -81,7 +86,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
8186
}
8287
CHECK_ESP_RESULT(result);
8388

84-
size_t ns_per_tick = 1e9 / 40000000;
89+
size_t ns_per_tick = 1e9 / clock_speed;
8590
uint16_t ws2812_t0h_ticks = WS2812_T0H_NS / ns_per_tick;
8691
uint16_t ws2812_t0l_ticks = WS2812_T0L_NS / ns_per_tick;
8792
uint16_t ws2812_t1h_ticks = WS2812_T1H_NS / ns_per_tick;

0 commit comments

Comments
 (0)