In order to be able to use SDIO interface and also I2S3 on a F4 Discovery board, I cut the traces going to the CS43L22 from PC10 and PC12 and connected them to PB3 and PB5 respectively, and appropriately remapped the GPIOs.
However I found that I am unable to send data on the I2S3 and simulatenously read another chunk of data from the SD card to enable continuous playback, it fails with a CRC Check Fail error on the sdcRead. After every I2S transfer I have to wait for TX to complete and then receive data from the SD Card before beginning another transmission.
The SDIO_STA register contains the value 1026 = (SDIO_STA_DBCKEND + SDIO_STA_DCRCFAIL bits)
So instead of using this code for double-buffered continuous playback:
Code: Select all
uint32_t t = 0;
bufSwitch = 0;
wf_read(&f1, buf, PLAYBACK_BUFFER_SIZE, &temp);
bytesToPlay-=temp;
wf_read(&f1, buf2, PLAYBACK_BUFFER_SIZE, &temp);
bytesToPlay-=temp;
codec_audio_send(buf, temp/sizeof(uint16_t));
while(bytesToPlay)
{
dmaWaitCompletion(i2sdma);
codec_audio_send(bufSwitch ? buf : buf2, temp / sizeof(uint16_t));
t = wf_read(&f1, bufSwitch ? buf2 : buf, PLAYBACK_BUFFER_SIZE, &temp);
bufSwitch = 1 - bufSwitch;
bytesToPlay-=temp;
}
I have to use this code which waits till reading completes before I can send another chunk [Which works, I get clear stereo audio, but playback is obviously glitchy]
Code: Select all
uint32_t t = 0;
bufSwitch = 0;
wf_read(&f1, buf, PLAYBACK_BUFFER_SIZE, &temp);
bytesToPlay-=temp;
wf_read(&f1, buf2, PLAYBACK_BUFFER_SIZE, &temp);
bytesToPlay-=temp;
codec_audio_send(buf, temp/sizeof(uint16_t));
while(bytesToPlay)
{
dmaWaitCompletion(i2sdma);
t = wf_read(&f1, bufSwitch ? buf2 : buf, PLAYBACK_BUFFER_SIZE, &temp);
codec_audio_send(bufSwitch ? buf : buf2, temp / sizeof(uint16_t));
bufSwitch = 1 - bufSwitch;
bytesToPlay-=temp;
}
I am unable to troubleshoot further, but suspect a hardware issue.
I attach the screenshot of the modded F4 board
The left trace cut was PC12 (SDIO_CK) and now connected to PB5 (Alt. I2S3_SD)
The right trace cut was PC10 (SDIO_D2) and now connected to PB3(Alt. I2S3_CK)