I2S one-off send
Posted: Mon Dec 17, 2018 7:01 pm
Hi,
I'm been trying to use the esp32 i2s driver to shift some data into shift registers in order to increase the number of available output (i've seen a few esp8266 samples about doing very similar things).
I'm trying to use the i2s driver to take care of some of the configuration but it seems like manually setting afterward to stop the clocks after each write isn't enough. I'm sure i'm missing something and I was just wondering if someone have any example or tips on how to get that going?
To give a bit more details, the plan is to be able to push some data to the i2s dma and have this data serially fed to the shift registers. So each would start the transmission of what's written (just 32bits in this case) and then stop both bclk and ws until the next time is called. I was expecting to stop the clocks once the FIFO is empty (when the 32bits have been sent?) but at the moment with the code below the same 4bytes are sent over and over again.
The current code i'm testing on is super basic, pretty much a copy paste of the sample code with the tx_stop_en
Thanks!
I'm been trying to use the esp32 i2s driver to shift some data into shift registers in order to increase the number of available output (i've seen a few esp8266 samples about doing very similar things).
I'm trying to use the i2s driver to take care of some of the configuration but it seems like manually setting
Code: Select all
I2S0.conf1.tx_stop_en = 1;
To give a bit more details, the plan is to be able to push some data to the i2s dma and have this data serially fed to the shift registers. So each
Code: Select all
i2s_write();
Code: Select all
i2s_write();
Code: Select all
tx_stop_en
The current code i'm testing on is super basic, pretty much a copy paste of the sample code with the tx_stop_en
Code: Select all
#include <Arduino.h>
#include "driver/i2s.h"
void setup() {
static const i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX),
.sample_rate = 44100,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
.intr_alloc_flags = 0, // default interrupt priority
.dma_buf_count = 8,
.dma_buf_len = 64,
.use_apll = false
};
static const i2s_pin_config_t pin_config = {
.bck_io_num = 26,
.ws_io_num = 25,
.data_out_num = 22,
.data_in_num = I2S_PIN_NO_CHANGE
};
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL); //install and start i2s driver
i2s_set_pin(I2S_NUM_0, &pin_config);
i2s_set_sample_rates(I2S_NUM_0, 44100); //set sample rates
I2S0.conf1.tx_stop_en = 1;
}
size_t written;
uint32_t data = 0xdeadbeef;
void loop() {
i2s_write(I2S_NUM_0, &data, 4, &written, portMAX_DELAY);
delay(5000);
}