2023-10-10 06:22 PM - edited 2023-10-10 08:50 PM
Hello,
Is there a way to disable the slot swapping of the I2S peripheral?
Take the following example, without any HAL_I2S callbacks...
void start_loopback(I2S_HandleTypeDef* is2_handle) {
printf("--> Starting algorithm loop back...\n");
for (int i=0; i<I2S_FRAME_SAMPLES; i++){
i2sTxBuffer[i] = i;
}
int hal_res = HAL_I2SEx_TransmitReceive_DMA(is2_handle, i2sTxBuffer, i2sRxBuffer, I2S_FRAME_SAMPLES);
if(hal_res != HAL_OK) {printf("I2S - HAL_I2SEx_TransmitReceive failed, hal_res = %d!\r\n", hal_res); HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);}
while(1){
vTaskDelay(100);
}
It unexpectedly produces the following on the receiving end:
1 0 3 2 5 4 7 6 9 8 11 10 13 12 15 14 17 16 19 18 21 20 23 22 25 24 27 26 29 28 31 30
As I'm consuming and producing I2S samples in software, there is no need for the swap, the DMA buffer will already be in an appropriate format to send over the I2S wire.
2023-10-10 11:05 PM
That looks like some DMA buffer / width mismatch.
Start simple, set all to WORD / 32 bit.
2023-10-10 11:49 PM
So this ended up being on the receiver side of things, the ESP32:
https://www.esp32.com/viewtopic.php?t=11023
Thanks!