SPI + ESP8266_RTOS_SDK
Posted: Sun Nov 14, 2021 12:11 pm
Hi,
This is my first try to use SPI with the ESP8266 and FreeRTOS but for some reason I there is only zeroes in the MISO buffer. The SPI device I am using is the MCP3008 10-bit ADC. I can see from my oscilloscope that the MCP3008 is returning data on the MISO line so I'm at a loss as to what's happening. Here are some code snippets to how I'm configuring the ESP and executing spi_trans.
The ESP8266 I'm using is the Adafruit HUZZAH board with the following pins hooked up to the MCP3008
Does anybody see what I could be doing incorrectly here to have MISO filled with 0's?
Thanks
This is my first try to use SPI with the ESP8266 and FreeRTOS but for some reason I there is only zeroes in the MISO buffer. The SPI device I am using is the MCP3008 10-bit ADC. I can see from my oscilloscope that the MCP3008 is returning data on the MISO line so I'm at a loss as to what's happening. Here are some code snippets to how I'm configuring the ESP and executing spi_trans.
Code: Select all
spi_config_t spi_config;
spi_config.interface.val = SPI_DEFAULT_INTERFACE;
spi_config.intr_enable.val = 0;
spi_config.event_cb = NULL;
spi_config.mode = SPI_MASTER_MODE;
spi_config.clk_div = SPI_2MHz_DIV;
spi_init(HSPI_HOST, &spi_config);
Code: Select all
spi_trans_t trans;
uint16_t cmd = SPI_MASTER_WRITE_DATA_TO_SLAVE_CMD;
uint32_t addr = 0;
uint32_t MOSI = 0x01800000;
uint32_t MISO = 0xFFFFFFFF;
trans.cmd = &cmd;
trans.addr = &addr;
trans.mosi = &MOSI;
trans.miso = &MISO;
trans.bits.cmd = 8;
trans.bits.addr = 0;
trans.bits.mosi = sizeof(MOSI) * 8;
trans.bits.miso = sizeof(MISO) * 8;
while(1)
{
spi_trans(HSPI_HOST, &trans);
ESP_LOGI(TAG, "Read %08x", MISO);
vTaskDelay(1000 / portTICK_RATE_MS);
}
The ESP8266 I'm using is the Adafruit HUZZAH board with the following pins hooked up to the MCP3008
Code: Select all
SPI ESP8266 MCP3008
CLK 14 13
SS 15 10
MOSI 13 11
MISO 12 12
Does anybody see what I could be doing incorrectly here to have MISO filled with 0's?
Thanks