MVP Logo

Материализуя идеи

Не поднимешься в горы — не узнаешь высоты неба; не спустишься в бездну — не узнаешь толщи земли.

I started ESP8266 project, the first step was to support SDMMC over SPI. I have implemented SDMMC SPI interface years ago. The main challenge was to adapt it to new MCU core. After many attempts, it was up and running. Below are lessons learned.

All in all, the main aim was to work-around the way, ESP HSPI treats MOSI level. It is 0 when inactive, i.e. all the time we reading SPI packets, slave receives 00s. No SDMMCs I know start communicating under these conditions. They expect high MOSI, as shown on picture below, taken from the same SDMMC code working on STM32 platform.

SDMMC over SPI. Platform - STM32F103xx
SDMMC over SPI. Platform - STM32F103xx

While, if used as-is, ESP8266 HSPI demonstrates the following MOSI behavior:

SDMMC over SPI. Platform - ESP8266. Default behavior (MOSI = 0 when reading, or idle, not working with SDMMC)
SDMMC over SPI. Platform -  ESP8266. Default behavior (MOSI = 0 when reading, or idle, not working with SDMMC)

What we have to do to work-around this, is to unconfigure MOSI function to GPIO13 output, while reading SPI, and set it to 1.
While, if we got to write to SPI, we heve to re-configure GPIO13 back to MOSI, and proceed as usual. After that, SDMMC starts answering, and initialization finally completes OK.

SDMMC over SPI, ESP8266, working HSPI work-arond, MOSI = 1 when reading.
SDMMC over SPI, ESP8266, working HSPI work-arond, MOSI = 1 when reading.

Below are excerpt files from the working SDMMC project.
After initialization code is successful (SDMMC is "open") we may use our storage elsewhere, for instance in famous ELM FAT FS library calls.

Яндекс.Метрика

Сейчас 47 гостей и ни одного зарегистрированного пользователя на сайте

14.12.2019  ©2019 - ExactSoft - All rights reserved