I2S: Why no 8 bits per channel

blippy
Posts: 17
Joined: Tue Jun 25, 2019 7:36 am

I2S: Why no 8 bits per channel

Postby blippy » Wed Nov 20, 2019 5:27 pm

I'm confused about I2s. Suppose I have the code:

Code: Select all

 esp_err_t ret;


        static const int i2s_num = 0; // i2s port number

        static const i2s_config_t i2s_config = {
                .mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN,
                .sample_rate = 8000,
                .bits_per_sample = 8,
                .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
                //.communication_format = I2S_COMM_FORMAT_I2S_MSB,
                .communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_PCM,
                .intr_alloc_flags = 0, // default interrupt priority
                .dma_buf_count = 8,
                .dma_buf_len = 64,
                .use_apll = false
        };

        ret = i2s_driver_install(i2s_num, &i2s_config, 0, NULL);        
        assert(ret == ESP_OK);

I get an assertion error

Code: Select all

E (6361) I2S: Invalid bits per sample
I'm puzzled. https://github.com/espressif/esp-idf/bl ... iver/i2s.h
clearly seems to allow for 8 bits per sample. See line 40. However, an error is raised if it is done. See
https://github.com/espressif/esp-idf/bl ... iver/i2s.c
line 333.
It is because

Code: Select all

bits < I2S_BITS_PER_SAMPLE_16BIT
Is that a bug in ESP-IDF? What's going on?

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

Re: I2S: Why no 8 bits per channel

Postby ESP_Sprite » Thu Nov 21, 2019 10:40 am

Even if there's a define for it, I don't think the I2S driver supports 8-bit. (Additionally, I think 8-bit is only supported on I2S channel 1 in hardware.)

blippy
Posts: 17
Joined: Tue Jun 25, 2019 7:36 am

Re: I2S: Why no 8 bits per channel

Postby blippy » Thu Nov 21, 2019 7:57 pm

Ah, interesting. I didn't know that. I need to experiment!

Who is online

Users browsing this forum: No registered users and 30 guests