#1:
Setting the clock speed on the SPI interface with the
Code: Select all
host.max_freq_khz
What is the correct way of changing the SPI clock to e.g. 10 Mhz?
#2:
Sporatic errors occur when running the ESP32 on 240 Mhz (no problems on 160 Mhz) SPI running @20 Mhz in both cases:
E (7064555) sdmmc_cmd: sdmmc_read_sectors_dma: sdmmc_send_cmd returned 0x108
E (7074555) diskio_sdmmc: sdmmc_read_blocks failed (264)
The SD SPI initialization code:
Code: Select all
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = false,
.max_files = 10,
.allocation_unit_size = 16 * 1024
};
sdmmc_host_t host = SDSPI_HOST_DEFAULT();
// Not sure if this makes any difference but now its done
host.flags |= SDMMC_HOST_FLAG_1BIT;
spi_bus_config_t bus_cfg = {
.mosi_io_num = PIN_NUM_MOSI,
.miso_io_num = PIN_NUM_MISO,
.sclk_io_num = PIN_NUM_CLK,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.max_transfer_sz = 4000,
};
ret = spi_bus_initialize(host.slot, &bus_cfg, 1);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize bus.");
return (1);
}
sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT();
slot_config.gpio_cs = PIN_NUM_CS;
slot_config.host_id = host.slot;
ret = esp_vfs_fat_sdspi_mount("/sdcard", &host, &slot_config, &mount_config, &card);
Code: Select all
esp_err_t err = (*card->host.do_transaction)(slot, cmd);
Any comments are welcome as I am a bit in the dark of what to try next?