I2S: why no 8 bits per sample?

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

I2S: why no 8 bits per sample?

Postby blippy » Fri Sep 27, 2019 3:14 pm

I'm curious as to why i2s_config_t doesn't allow a bits_per_sample of 8. Given that the DAC pins are only 8 bits, surely it would make sense?

It means that we have to either pad our samples or store/transmit twice as much data as we need.

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

Re: I2S: why no 8 bits per sample?

Postby blippy » Fri Sep 27, 2019 9:07 pm

OK, I thought I solved things just now, but apparently not. I've got

Code: Select all

        static const int i2s_num = 0; // i2s port number
   
#define RATE 8000

        static const i2s_config_t i2s_config = {
                .mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN,
                .sample_rate = RATE,
                .bits_per_sample = I2S_BITS_PER_SAMPLE_8BIT,
                .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
                .communication_format = I2S_COMM_FORMAT_I2S,
                .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);

But I get an assertion error, with the message

Code: Select all

E (7650) I2S: Invalid bits per sample
How do I fix this?

Also, I'm confused as to how I should set .dma_buf_count and .dma_buf_len. I assume it's got something to do with how you can buffer input, but the documentation doesn't decribe how to set or use them. They're just kinda magic numbers as far as I'm concerned.

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

Re: I2S: why no 8 bits per sample?

Postby blippy » Fri Sep 27, 2019 10:22 pm

Just a follow-up. Here is sets the bits per sample to be 8:
https://esp-idf-zh.readthedocs.io/zh_CN ... s/i2s.html

I still couldn't get my code to work properly, though.

Who is online

Users browsing this forum: Bing [Bot] and 35 guests