Page 1 of 2

D1 Mini & VS1053b

Posted: Sun Mar 22, 2020 9:31 pm
by SIGTERM
Hi folks,

my name is Chris and i try to get some sound out of an esp8266 with vs1053b.
I wired it as i think is correct ......so my code runs, but when i read from SPI, i always get FFFFFFFF. As well as it doesn't play a tone.
I tried to port the vs1053 adafruit circuitpy module (https://github.com/adafruit/Adafruit_Ci ... hon_VS1053).

What am i doing wrong?

init is:
self._xcs = Pin(xcs, Pin.OUT)
self._xdcs = Pin(xdcs, Pin.OUT)
self._dreq = Pin(dreq, Pin.IN)
self._spi = SPI(1, baudrate=_COMMAND_BAUDRATE, polarity=0, phase=0 )

reading :
self._SCI_SPI_BUFFER[0] = _VS1053_SCI_READ
self._SCI_SPI_BUFFER[1] = address & 0xFF
self._spi.init(baudrate=_COMMAND_BAUDRATE)
self._spi.write(self._SCI_SPI_BUFFER)
self._spi.readinto(self._SCI_SPI_BUFFER)

Regards,
Chris

Re: D1 Mini & VS1053b

Posted: Mon Mar 23, 2020 12:30 am
by jimmo
Hi,

I don't see anywhere in your code where you're using the self._xcs pin (which I assume is your chip select). I'd expect to see it being set low before the operation, then high afterwards. (Chip select is generally active low).

(Similarly with _xdcs (not sure what that is? is it a Data/Command pin?)

Re: D1 Mini & VS1053b

Posted: Mon Mar 23, 2020 5:08 pm
by SIGTERM
Ok...you're right....i left out that part:
self._xdcs(0)
self._xcs(0)

i tried that in all variants.......just before and after operations.

oh...according to https://cdn.sparkfun.com/datasheets/Dev ... S1053B.pdf xdcs is "Data chip select / byte sync" .
Or in the SDI description it's "data interface chip select"....

Re: D1 Mini & VS1053b

Posted: Mon Apr 20, 2020 7:00 pm
by SIGTERM
So nobody can help me? Or give me a hint?
Please :-D

Re: D1 Mini & VS1053b

Posted: Tue Apr 21, 2020 2:55 am
by jimmo
SIGTERM wrote:
Mon Apr 20, 2020 7:00 pm
So nobody can help me? Or give me a hint?
Please :-D
Could you post the latest version of your code. I'm not quite sure I followed what you said about setting cs to zero (do you also set it back to 1 again after the operation?).

Re: D1 Mini & VS1053b

Posted: Thu Apr 23, 2020 5:49 am
by pythoncoder
@SIGTERM You might like to read this.

tl;dr According to Adafruit's own code comments their driver doesn't actually work. :o

Re: D1 Mini & VS1053b

Posted: Thu Apr 23, 2020 6:01 pm
by gyroing
this code works on esp32 micropython : https://github.com/urish/vs1053-circuitpython with little modification

Re: D1 Mini & VS1053b

Posted: Fri Apr 24, 2020 6:08 am
by pythoncoder
That is interesting, it looks like he's done a good job of speeding up the response to the DREQ line. I wonder why Adafruit haven't taken this up?

Since DREQ is a physical pin it would seem to offer the possibility of using an IRQ. From a quick look at the datasheet the VS1053b has a 2KiB FIFO buffer. If an MP3 has a bitrate of 128Kbps that's 16KiB/s so the buffer holds 125ms of sound. On the face of it MicroPython on an ESP8266 should be able to keep up with this easily. Am I missing something here? I wonder where the problem is.

Re: D1 Mini & VS1053b

Posted: Fri Apr 24, 2020 10:15 am
by gyroing
i wonder is there any replace function for "spi.try_lock()" and "spi.unlock()" in mocropython, i removed these line form micropython code @ https://github.com/urish/vs1053-circuitpython and change the gpio acording to micropython - i could run internet radio . but wand to find the way to replace spi lock and unlock.

Re: D1 Mini & VS1053b

Posted: Fri Apr 24, 2020 10:40 am
by pythoncoder
Yes. I have ported code from Adafruit replacing their bus classes with straight I2C or SPI, for example this RA8875 driver. The object of the bus device code is simplify sharing the bus between multiple devices. They have a different approach to coding, prioritising ease of use by complete beginners over performance. It can make their code quite hard to follow.

The general MicroPython approach is rather the converse, prioritising small code size, performance and readability, potentially at the cost of assuming some degree of experience on the part of users.