Hi, there.
I try to work out a DRV8305 board and cannot get the SPI working. The SPI signals on the MCU side works as expected but there is no SDO responds from DRV8305.
I searched around and there is a post about adding a pullup for the SDO line, any suggestion? Thank you!
The MCU is the esp32 and the code snippet is
#include <stdio.h> #include <string.h> #include "sdkconfig.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_system.h" #include "esp_spi_flash.h" #include "driver/spi_master.h" #include "driver/gpio.h" #include "esp_task_wdt.h" #define GPIO_EN_GATE 22 #define GPIO_nFAULT 17 #define GPIO_PWRGD 16 uint32_t read_spi_register(spi_device_handle_t spi, uint8_t read_high, uint8_t read_low) { uint8_t command_reg[2]; command_reg[0] = read_high; command_reg[1] = read_low; uint8_t read_reg[4] = {0}; esp_err_t ret; spi_transaction_t t; memset(&t, 0, sizeof(t)); t.length=16; t.tx_buffer = &command_reg; t.rx_buffer = &read_reg; t.user=(void*)0; ret = spi_device_acquire_bus(spi, portMAX_DELAY); assert(ret==ESP_OK); ret=spi_device_polling_transmit(spi, &t); //ret = spi_device_transmit(spi, &t); assert(ret==ESP_OK); spi_device_release_bus(spi); return *(uint32_t*)t.rx_data; } void app_main(void) { printf("Hello world!\n"); /* Print chip information */ esp_chip_info_t chip_info; esp_chip_info(&chip_info); printf("This is %s chip with %d CPU cores, WiFi%s%s, ", CONFIG_IDF_TARGET, chip_info.cores, (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); printf("silicon revision %d, ", chip_info.revision); printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); printf("Free heap: %d\n", esp_get_free_heap_size()); /* config drv8305 */ gpio_set_direction(GPIO_EN_GATE, GPIO_MODE_OUTPUT); gpio_set_level(GPIO_EN_GATE, 0); gpio_set_direction(GPIO_nFAULT, GPIO_MODE_INPUT); gpio_set_direction(GPIO_PWRGD, GPIO_MODE_INPUT); vTaskDelay(1 / portTICK_PERIOD_MS); /* query drv8305 */ printf("Starting spi...\n"); esp_err_t ret; spi_device_handle_t spi; spi_bus_config_t buscfg={ .miso_io_num=19, .mosi_io_num=23, .sclk_io_num=18, .quadwp_io_num=-1, .quadhd_io_num=-1, .max_transfer_sz=0 }; spi_device_interface_config_t devcfg={ .clock_speed_hz=1*1000, .mode=1, //SPI mode 0 .spics_io_num=5, .queue_size=2, .cs_ena_pretrans = 10, }; ret=spi_bus_initialize(VSPI_HOST, &buscfg, 2); ESP_ERROR_CHECK(ret); ret=spi_bus_add_device(VSPI_HOST, &devcfg, &spi); ESP_ERROR_CHECK(ret); /* wait and quit */ int counter = 0; gpio_set_level(GPIO_EN_GATE, 1); while (true) { counter += 1; read_spi_register(spi, 0x1 << 7 | 0x0 << 2 , 0x0); read_spi_register(spi, 0x1 << 7 | 0x5 << 2 , 0x0); read_spi_register(spi, 0x1 << 7 | 0x7 << 2 , 0x0); vTaskDelay(20 / portTICK_PERIOD_MS); } }
The SDO/MISO signal shows up like this
While the SCLK, nSCS and MOSI looks like fine
The following is the SCLK and MOSI
The following is the SCLK and nSCS
The schematic used for the board is