Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_esp32_psram_cs_hold_time_issue_when_under_80…
Browse files Browse the repository at this point in the history
…m' into 'master'

esp_psram: fix esp32 psram cs hold time issue when under 40m

Closes IDF-5761

See merge request espressif/esp-idf!19393
  • Loading branch information
Icarus113 committed Aug 18, 2022
2 parents b738321 + 02fb570 commit 6c35aa6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions components/esp_psram/esp32/esp_psram_impl_quad.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,14 @@ typedef enum {
} psram_cache_speed_t;

#if CONFIG_SPIRAM_SPEED_40M && CONFIG_ESPTOOLPY_FLASHFREQ_40M
#define PSRAM_SPEED PSRAM_CACHE_F40M_S40M
#define PSRAM_SPEED PSRAM_CACHE_F40M_S40M
#define PSRAM_CS_HOLD_TIME 0
#elif CONFIG_SPIRAM_SPEED_40M && CONFIG_ESPTOOLPY_FLASHFREQ_80M
#define PSRAM_SPEED PSRAM_CACHE_F80M_S40M
#define PSRAM_SPEED PSRAM_CACHE_F80M_S40M
#define PSRAM_CS_HOLD_TIME 0
#elif CONFIG_SPIRAM_SPEED_80M && CONFIG_ESPTOOLPY_FLASHFREQ_80M
#define PSRAM_SPEED PSRAM_CACHE_F80M_S80M
#define PSRAM_SPEED PSRAM_CACHE_F80M_S80M
#define PSRAM_CS_HOLD_TIME 1
#else
#error "FLASH speed can only be equal to or higher than SRAM speed while SRAM is enabled!"
#endif
Expand Down Expand Up @@ -680,7 +683,7 @@ void psram_set_cs_timing(psram_spi_num_t spi_num, psram_clk_mode_t clk_mode)
if (clk_mode == PSRAM_CLK_MODE_NORM) {
SET_PERI_REG_MASK(SPI_USER_REG(spi_num), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
// Set cs time.
SET_PERI_REG_BITS(SPI_CTRL2_REG(spi_num), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S);
SET_PERI_REG_BITS(SPI_CTRL2_REG(spi_num), SPI_HOLD_TIME_V, PSRAM_CS_HOLD_TIME, SPI_HOLD_TIME_S);
SET_PERI_REG_BITS(SPI_CTRL2_REG(spi_num), SPI_SETUP_TIME_V, 0, SPI_SETUP_TIME_S);
} else {
CLEAR_PERI_REG_MASK(SPI_USER_REG(spi_num), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
Expand Down

0 comments on commit 6c35aa6

Please sign in to comment.