Skip to content

i2s transmit (GIT8266O-747) #1169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ttennebb opened this issue Jan 19, 2022 · 2 comments
Open

i2s transmit (GIT8266O-747) #1169

ttennebb opened this issue Jan 19, 2022 · 2 comments

Comments

@ttennebb
Copy link

if (xQueueReceive(p_i2s_obj[i2s_num]->tx->queue, &p_i2s_obj[i2s_num]->tx->curr_ptr, ticks_to_wait) == pdFALSE) {

When I tried the example code for i2s, the esp8266 would hang. After much gnashing of teeth, I finally found the culprit.
In the subroutine, esp_err_t i2s_write(), the line :
if (xQueueReceive(p_i2s_obj[i2s_num]->tx->queue, &p_i2s_obj[i2s_num]->tx->curr_ptr, ticks_to_wait) == pdFALSE) {
should be :
if (xQueueSend(p_i2s_obj[i2s_num]->tx->queue, &p_i2s_obj[i2s_num]->tx->curr_ptr, ticks_to_wait) == pdFALSE) {

@github-actions github-actions bot changed the title i2s transmit i2s transmit (GIT8266O-747) Jan 19, 2022
@ttennebb
Copy link
Author

I found it because I found no errors on the initial runs, but no data/clock coming out any gpio.
First blush, the original line with xQueueReceive would fail (of course) then break out of the while loop, give back the semaphore, returning ESP_OK. No error being logged or handed back.

    if (p_i2s_obj[i2s_num]->tx->rw_pos == p_i2s_obj[i2s_num]->tx->buf_size || p_i2s_obj[i2s_num]->tx->curr_ptr == NULL) {        
        if (xQueueReceive(p_i2s_obj[i2s_num]->tx->queue, &p_i2s_obj[i2s_num]->tx->curr_ptr, ticks_to_wait) == pdFALSE) {
            break;
        }
        p_i2s_obj[i2s_num]->tx->rw_pos = 0;
    }

This will throw an error in a log or on screen when monitoring :

    if (p_i2s_obj[i2s_num]->tx->rw_pos == p_i2s_obj[i2s_num]->tx->buf_size || p_i2s_obj[i2s_num]->tx->curr_ptr == NULL) {        
        if (xQueueReceive(p_i2s_obj[i2s_num]->tx->queue, &p_i2s_obj[i2s_num]->tx->curr_ptr, ticks_to_wait) == pdFALSE) {
            ESP_LOGE(I2S_TAG, "Time out waiting for ticks_to_wait : %d", ticks_to_wait);
            break;
        }
        p_i2s_obj[i2s_num]->tx->rw_pos = 0;
    }

That would at least send out some notification as to where to look.
Or better still :

    I2S_CHECK((xQueueReceive(p_i2s_obj[i2s_num]->tx->queue, &p_i2s_obj[i2s_num]->tx->curr_ptr, ticks_to_wait) == pdTRUE), "Time out waiting for ticks_to_wait", ESP_ERR_TIMEOUT);

Hope this helps. Thanks for all your efforts!

@tieutuanbao
Copy link

Too long time for this issue ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants