1
votes

I am taking a shot at writing a wrapper for the S1V30120 dectalk text synthesis IC in C language using the ESP IDF. I am running into a problem in the following code.

printf("Hello world!\n");
esp_err_t ret;
spi_device_handle_t spi;
spi_bus_config_t buscfg={
    .miso_io_num=PIN_NUM_MISO,
    .mosi_io_num=PIN_NUM_MOSI,
    .sclk_io_num=PIN_NUM_CLK,
    .quadhd_io_num=-1,
    .quadwp_io_num=-1
};
spi_device_interface_config_t devcfg={
    .clock_speed_hz=750000,
    .mode=0,
    .spics_io_num=PIN_NUM_CS,
    .queue_size=7
};
ret=spi_bus_initialize(HSPI_HOST, &buscfg, 1);
assert(ret==ESP_OK);

ret=spi_bus_add_device(HSPI_HOST, &devcfg, &spi);
uint8_t rec[20];
assert(ret==ESP_OK);
uint8_t cmd[] = {0xAA, 0x04, 0x00, 0x05, 0x00}; // get information command
printf("waiting for rdy");
while (gpio_get_level(PIN_NUM_RDY) == 0){};
//create 2 transactions 1 for transmitting the GET INFORMATION command
//and 1 for getting the data back from the ic
spi_transaction_t t;
spi_transaction_t r;
memset(&t, 0, sizeof(t));
t.length=5*8;
t.tx_buffer=&cmd;
r.length=20*8;
r.rx_buffer=&rec;

ret = spi_device_transmit(spi, &t);
assert( ret == ESP_OK);
ret = spi_device_transmit(spi, &r);
assert(ret == ESP_OK);
printf((char*)r.rx_data);
/* Print chip information */
printf("Restarting now.\n");

I'm pretty sure connection should be in full duplex mode and I believe that is set up correctly. the information coming back should be 20 bytes but I am getting the error

rxdata transfer > 32 bits without configured DMA

at the moment I am following 2 pieces of code that may help.

an example of using SPI in the esp idf: https://github.com/espressif/esp-idf/blob/3276a1316f66a923ee2e75b9bd5c7f1006d160f5/examples/peripherals/spi_master/main/spi_master_example_main.c

an example of using the dectalk ic in Arduino ide: https://electronza.com/arduino-due-s1v30120-text-speech-code/2/

the dectalk ic protocol sheet: https://github.com/MikroElektronika/Click_TextToSpeech_S1V30120/blob/master/datasheet/S1V30120%20Protocol%20Specification.pdf

and the SPI documentation for the esp idf: https://gitdemo.readthedocs.io/en/latest/api/peripherals/spi_master.html

the protocol sheet also says something about sending 16 bytes of 0x00 after a transaction I've never seen that before though.

I hope I was thorough enough with all this information and I thank anyone in advance who can help!

1

1 Answers

1
votes

You have used "1" for DMA in the line

ret=spi_bus_initialize(HSPI_HOST, &buscfg, 1);

But as mentioned in the docs, the DMA needs to be configured. For external PSRAM available on these boards that means something like

pvPortMallocCaps(20, MALLOC_CAP_DMA)

Without DMA only 32 bits data are possible per transaction.