Post topics, source code that relate to the Arduino Platform

User avatar
By masterglob
#83970 Hello,

I have been trying to read a file from SD card (with micro SD card shield) and output the stereo samples to the I2C (on a PCM5102), but I have trouble making both in the mean time:

- HW: Wemos D1 (started at 160Mhz)
- I can generate a sound on PCM
- I can read files from SD card.
- I use a SPI 2*16 display for text
Mapping I used:

I2C (LCD display):
- D1 => SCL
- D2 => SDA

I2S (Audio out)
- D4 => WS
- D8 => SCK
- RX => SD

SPI (SD Card)
- D0 => CS (I tried with D3 also)
- D5 => SCK
- D6 => MISO
- D7 => MOSI

Power :
- Wemos + I2C have power from front micro USB
- SD card + PCM have power from an external 5V micro USB charger (plugged on a charger, not on PC USB)

I do not see where I have a HW conflict, so I guess there is a SW issue somewhere.
For information:
I use several buffers of 256 samples to have enough pre-read data even if SD card is temporarily slow (I need about 4.5 ms to read buffer -up to 6ms sometimes- and it covers 5.8 ms of sound, which is globally ok).
I check that I do not get data underflow (i.e I never have i2s_is_empty() ), even after SD card read or yield. So it seems I put data correctly and in time in I2S.

However, I can't get any sound, and if I add for example a sine to my wavform it does not ouptut either as long as the SD card is in use.
If I continue after file end, the output is noisy (even for sine wave) and I need to call again the I2S setup so that it come OK again:
Code: Select all   i2s_begin();
   i2s_set_rate(44100);


Does anyone know if there is a limitation with I2S while using SD card? May this be a power issue?

Thanks for help!