I2S Receive bug causing garbage data?
Posted: Wed Mar 22, 2017 6:57 am
Trying to receive audio via I2S from a single mic but there seems to be two issues:
1) With a single mic, you'd expect to see an interleaving of left and right channels, where one channel has data and the other is zeros . Instead, I'm seeing periods of data on both channels and then zeros on both channels; then data; then zeros. See "SAMPLE DATA" below.
2) When the data is averaged, the averaged should be similar for similar volume levels. Interestingly, during a single "run" the averages are similar. However, when the ESP32 is reset, the average changes. It's as though there is some timing issue that changes when the ESP32 is reset. See "AVERAGES FROM SAMPLE RUNS" below.
Maybe there's some additional setup required?
SAMPLE DATA
1) With a single mic, you'd expect to see an interleaving of left and right channels, where one channel has data and the other is zeros . Instead, I'm seeing periods of data on both channels and then zeros on both channels; then data; then zeros. See "SAMPLE DATA" below.
2) When the data is averaged, the averaged should be similar for similar volume levels. Interestingly, during a single "run" the averages are similar. However, when the ESP32 is reset, the average changes. It's as though there is some timing issue that changes when the ESP32 is reset. See "AVERAGES FROM SAMPLE RUNS" below.
Maybe there's some additional setup required?
Code: Select all
static void init_i2s()
{
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_RX, // Receive
.sample_rate = SAMPLE_RATE,
.bits_per_sample = BITS_PER_SAMPLE,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB,
.dma_buf_count = 14, // number of buffers, 128 max.
.dma_buf_len = 32*2, // size of each buffer
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1 //Interrupt level 1
};
i2s_pin_config_t pin_config = {
.bck_io_num = 26,
.ws_io_num = 25,
.data_in_num = 22,
.data_out_num = I2S_PIN_NO_CHANGE //was -1
};
i2s_driver_install(I2S_NUM, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM, &pin_config);
}
SAMPLE DATA
AVERAGES FROM SAMPLE RUNS255 255 78 16 0 0 205 13 0 0 253 9 255 255 69 6 0 0 251 3 0 0 37 3 255 255 75 3 255 255 19 4 255 255 113 5 0 0 18 7 255 255 62 9 0 0 63 11 0 0 25 13 0 0 132 14 255 255 104 15 255 255 201 15 0 0 206 15 0 0 131 15 255 255 235 14 0 0 15 14 0 0 220 12 0 0 90 11 0 0 73 9 255 255 172 6 255 255 131 3 255 255 26 0 0 0 102 252 0 0 222 248 0 0 239 245 255 255 193 243 0 0 28 242 0 0 31 241 255 255 139 240 255 255 40 240 0 0 186 239 255 255 42 239 255 255 116 238 255 255 194 237 255 255 71 237 0 0 12 237 255 255 33 237 0 0 84 237 0 0 192 237 0 0 75 238 255 255 239 238 0 0 148 239 255 255 70 240 0 0 255 240 255 255 211 241 255 255 188 242 0 0 223 243 0 0 252 244 0 0 28 246 0 0 238 246 255 255 194 247 255 255 128 248 255 255 74 249 255 255 250 249 0 0 167 250 0 0 52 251 0 0 160 251 255 255 181 251 255 255 188 251 255 255 255 251 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 146 252 0 0 151 253 0 0 19 255 0 0 248 0 255 255 75 3 255 255 193 5 0 0 239 7 0 0 209 9 0 0 21 11 0 0 188 11 255 255 168 11 255 255 19 11 0 0 75 10 0 0 158 9 255 255 30 9 255 255 124 8 0 0 165 7 0 0 200 6 0 0 9 6 255 255 107 5 255 255 184 4 255 255 200 3 0 0 158 2 0 0 102 1 0 0 23 0 0 0 216 254 255 255 206 253 255 255 14 253 255 255 163 252 0 0 143 252 255 255 168 252 0 0 234 252 255 255 113 253 255 255 27 254 255 255 176 254 0 0 21 255 0 0 50 255 0 0 245 254 0 0 109 254 0 0 167 253 255 255 192 252 255 255 213 251 255 255 97 251 0 0 192 251 255 255 216 252 255 255 49 254 255 255 69 255 0 0 61 0 255 255 11 1 0 0 65 2 0 0 143 4 0 0 102 7 255 255 140 9 255 255 129 11 0 0 151 13 255 255 206 16 255 255 93 21 0 0 205 26 255 255 96 32 255 255 196 37 255 255 130 42 0 0 248 44 255 255 241 44 255 255 12 43 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 181 39 255 255 119 35 0 0 132 30 0 0 183 25 255 255 173 20 255 255 14 16 0 0 88 12 0 0 92 10 255 255 144 10 255 255 110 12 255 255 123 15 255 255 49 19 255 255 157 22 0 0 229 24 255 255 127 25 0 0 80 24 0 0 12 22 0 0 141 19 255 255 226 17 255 255 188 17 0 0 93 19 255 255 81 22 255 255 56 26 0 0 229 29 0 0 33 33 255 255 28 35 0 0 4 35 255 255 41 33 255 255 226 29 255 255 91 26 255 255 208 22 255 255 242 19 0 0 253 17 255 255 21 17 255 255 73 17 0 0 249 17 255 255 232 18 255 255 201 19 255 255 217 20 255 255 33 22 255 255 225 23 0 0 191 25 255 255 61 27 255 255 146 27 0 0 163 26 255 255 247 24 255 255 227 22 255 255 142 20 0 0 73 18 255 255 172 16 0 0 219 14 0 0 136 12 255 255 60 10 255 255 234 8 255 255 219 8 255 255 51 10 255 255 41 12 255 255 147 14 0 0 239 17 0 0 63 22 0 0 176 26 255 255 78 30 255 255 191 32 0 0 251 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 169 30 255 255 188 25 0 0 228 18 0 0 42 11 255 255 234 3 0 0 231 253 0 0 106 249 255 255 127 246 255 255 17 245 255 255 13 245 255 255 103 246 0 0 224 248 0 0 57 252 255 255 228 255 255 255 80 3 255 255 209 5 255 255 192 6 255 255 25 6 255 255 241 3 0 0 249 0 0 0 218 253 0 0 20 251 255 255 207 248 0 0 25 247 0 0 215 245 255 255 24 245 255 255 207 244 255 255 29 245 0 0 129 245 255 255 109 245 0 0 85 244 0 0 65 242 0 0 161 239 0 0 90 237 0 0 12 236 0 0 14 236 0 0 39 237 0 0 251 238 255 255 10 241 0 0 229 242 255 255 121 244 255 255 189 245 255 255 6 247 255 255 72 248 0 0 155 249 255 255 166 250 0 0 10 251 0 0 129 250 0 0 83 249 255 255 71 248 255 255 175 247 255 255 93 247 255 255 75 247 255 255 77 247 255 255 162 247 255 255 98 248 0 0 189 249 255 255 107 251 255 255 52 253 0 0 217 254 255 255 50 0 0 0 6 1 255 255 92 1 255 255 47 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Run 1
Left AVG=1072910535, Right AVG=1051371210
Left AVG=1072910538, Right AVG=1051371213
Left AVG=1072910532, Right AVG=1051371207
Left AVG=1072910539, Right AVG=1051371215
Run 2
Left AVG=1084774514, Right AVG=1046304599
Left AVG=1084774511, Right AVG=1046304599
Left AVG=1084774512, Right AVG=1046304598
Left AVG=1084774513, Right AVG=1046304598
Left AVG=1084774511, Right AVG=1046304597
Run 3
Left AVG=1096628631, Right AVG=1049588635
Left AVG=1096628631, Right AVG=1049588634
Left AVG=1096628631, Right AVG=1049588633
Left AVG=1096628636, Right AVG=1049588641
Left AVG=1096628629, Right AVG=1049588632
Run 4
Left AVG=1079489643, Right AVG=1028063152
Left AVG=1079489643, Right AVG=1028063154
Left AVG=1079489643, Right AVG=1028063151
Left AVG=1079489639, Right AVG=1028063150
Left AVG=1079489642, Right AVG=1028063153