Page 1 of 1
i2s interface confusion / i2s_write_bytes
Posted: Thu Sep 28, 2017 11:05 pm
by Rocker
I'm looking at the i2s example (i2s_example_main.c from 2.0 rc1) and am really confused by something. The setup_triangle_sine_waves function creates what looks like 1 wave form of 100 Hz data (10 msec) and sends it to the i2s via i2s_write_bytes. The main loop then delays for 5000 msec. I don't understand what the i2s is sending out. It should underrun almost the whole time. Does it continue to send out the last buffer received and just loop it until it gets new data?
Re: i2s interface confusion / i2s_write_bytes
Posted: Fri Sep 29, 2017 2:43 pm
by Rocker
As a follow-on to this, how is the driver user supposed to know when the transmit buffer needs more data. I see the interrupt handler in i2s.c which has an underrun case, but I don't know how that is supposed to get relayed on to the driver's user so that the application can send more data buffers to the driver.
Re: i2s interface confusion / i2s_write_bytes
Posted: Sat Sep 30, 2017 1:03 am
by ESP_Sprite
Normally, the i2c_write_bytes function blocks. You can just start up a thread that writes bytes as fast as it can using that function, and the blocking behaviour will make sure the timing is OK.
Also, yes, I think the current behaviour of the I2S-driver is to repeat the last sample buffer if it does not get new information.