Skip to content

Commit

Permalink
espressif: Fix ParallelBus clock speed
Browse files Browse the repository at this point in the history
The observed does not match the datasheet, so go with what was
observed.
  • Loading branch information
jepler committed Sep 23, 2021
1 parent 3f4bbc5 commit 298ea57
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ports/espressif/i2s_lcd_esp32s2_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ static esp_err_t i2s_lcd_reg_config(i2s_dev_t *i2s_dev, uint16_t data_width, uin
i2s_dev->clkm_conf.clkm_div_num = 2; // 160MHz / 2 = 80MHz
i2s_dev->clkm_conf.clkm_div_b = 0;
i2s_dev->clkm_conf.clkm_div_a = 0;
i2s_dev->clkm_conf.clk_sel = 2;
i2s_dev->clkm_conf.clk_sel = 2; // PLL_160M_CLK
i2s_dev->clkm_conf.clk_en = 1;

i2s_dev->conf.val = 0;
Expand All @@ -211,7 +211,17 @@ static esp_err_t i2s_lcd_reg_config(i2s_dev_t *i2s_dev, uint16_t data_width, uin
i2s_dev->conf2.lcd_en = 1;

// Configure sampling rate
i2s_dev->sample_rate_conf.tx_bck_div_num = 40000000 / clk_freq; // Fws = Fbck / 2
// The datasheet states that Fws = Fbck / (W*2), but empirically storing
// 1 in the register gives the highest value of 5MHz (and storing 0 causes
// a freeze instead of acting as though 64 was specified).
int div_num = 5000000 / clk_freq;
if (div_num == 0) {
div_num = 1;
}
if (div_num > 63) {
div_num = 63;
}
i2s_dev->sample_rate_conf.tx_bck_div_num = div_num;
i2s_dev->sample_rate_conf.tx_bits_mod = data_width;
// Configuration data format

Expand Down

0 comments on commit 298ea57

Please sign in to comment.