Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_120_ddr_pll_cali_issue' into 'master'
Browse files Browse the repository at this point in the history
mspi: fixed bbpll calibration issue

Closes IDF-8237

See merge request espressif/esp-idf!25934
  • Loading branch information
Icarus113 committed Sep 14, 2023
2 parents a5caa1c + d85c962 commit 7894b21
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions components/esp_hw_support/mspi_timing_by_mspi_delay.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,21 @@ static bool get_working_pll_freq(const uint8_t *reference_data, bool is_flash, u
uint32_t min_freq = big_num;
rtc_xtal_freq_t xtal_freq = rtc_clk_xtal_freq_get();

//BBPLL CALIBRATION START
regi2c_ctrl_ll_bbpll_calibration_start();
for (int pll_mhz_tuning = MSPI_TIMING_PLL_FREQ_SCAN_RANGE_MHZ_MIN; pll_mhz_tuning <= MSPI_TIMING_PLL_FREQ_SCAN_RANGE_MHZ_MAX; pll_mhz_tuning += 8) {
//bbpll calibration start
regi2c_ctrl_ll_bbpll_calibration_start();

/**
* pll_mhz = xtal_mhz * (oc_div + 4) / (oc_ref_div + 1)
*/
clk_ll_bbpll_set_frequency_for_mspi_tuning(xtal_freq, pll_mhz_tuning, ((pll_mhz_tuning / 4) - 4), 9);

//wait calibration done
while(!regi2c_ctrl_ll_bbpll_calibration_is_done());

//bbpll calibration stop
regi2c_ctrl_ll_bbpll_calibration_stop();

memset(read_data, 0, MSPI_TIMING_TEST_DATA_LEN);
if (is_flash) {
mspi_timing_config_flash_read_data(read_data, MSPI_TIMING_FLASH_TEST_DATA_ADDR, MSPI_TIMING_TEST_DATA_LEN);
Expand All @@ -380,15 +387,15 @@ static bool get_working_pll_freq(const uint8_t *reference_data, bool is_flash, u

//restore PLL config
clk_ll_bbpll_set_freq_mhz(previous_config.source_freq_mhz);
//bbpll calibration start
regi2c_ctrl_ll_bbpll_calibration_start();
//set pll
clk_ll_bbpll_set_config(previous_config.source_freq_mhz, xtal_freq);

//WAIT CALIBRATION DONE
//wait calibration done
while(!regi2c_ctrl_ll_bbpll_calibration_is_done());

//BBPLL CALIBRATION STOP
//bbpll calibration stop
regi2c_ctrl_ll_bbpll_calibration_stop();


*out_max_freq = max_freq;
*out_min_freq = min_freq;

Expand Down

0 comments on commit 7894b21

Please sign in to comment.