i2s interface confusion / i2s_write_bytes

Rocker
Posts: 24
Joined: Fri Apr 21, 2017 10:30 pm

i2s interface confusion / i2s_write_bytes

Postby Rocker » Thu Sep 28, 2017 11:05 pm

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?

Rocker
Posts: 24
Joined: Fri Apr 21, 2017 10:30 pm

Re: i2s interface confusion / i2s_write_bytes

Postby Rocker » Fri Sep 29, 2017 2:43 pm

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.

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

Re: i2s interface confusion / i2s_write_bytes

Postby ESP_Sprite » Sat Sep 30, 2017 1:03 am

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.

Who is online

Users browsing this forum: Baidu [Spider] and 128 guests