Explicitly define GPIO Pins for SD Fat MP3 Player #1671
-
This maybe more appropriate fielded to SD Fat library referenced in example linked below. However, I don't see much discussion going on there. How does one explicitly define the SD / SPI interface pins in MP3 player example linked above? I'm reading SD Fat library documentation and code but unsure how to do explicitly define the pins. The backstory.... I wired my board per directions in example readme. However, reports error in terminal: PIN CONFIG
TERMINAL ERROR
I suspected issue with my board and or wiring. Loaded Arduino examples for SD titled "SD_Test" & "SD_Time". Explicitly defined the GPIO pins as per the example above. Both examples worked perfectly validating my board is wired correctly. I also probed all the signals with my oscope... They made since (SCLK, CS, DI, DO). Then I loaded back up the MP3 example per above. And probed the SD signals as well. CS, SCLK, were good. However, nothing on DI or DO. Hence why I want to explicitly define the GPIO pins to ensure code is correct too. Additionally, not sure how the error codes work? Linked below. I'm assuming the cmd: 0x00 is an error code? But that code per link below is "No error". Not sure if or even how to output the error codes (maybe their interpreted already? in that statement "Card Failed!" https://github.com/greiman/SdFat/blob/master/doc/SdErrorCodes.txt |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
UPDATE: The readme seems to be relying on defaults in ESP32 / Arduino Library code. The library my IDE pulled down doesn't seem to match the one readme was built with (pin defines in readme file). Once I rewired the board to match the library (not the readme file) I got the example working. Was able to locate SS definition traversing code from AudioSourceSD call in example code. I'm not exactly sure where other pins are setup but seems those are the correct pins and not the ones shown in readme, at least in my instance. I'm not sure what best practice is anymore for coding. I've been out of the game for a while so forgive my novice. However, it's nice to have hardware defines broken out somewhere easy to find / explicitly define if necessary. Forgive me if I missed that somewhere in the code. These library's you wrote are AWESOME. It would have taken me months if not years to do this. Really cool. Thanks for sharing! |
Beta Was this translation helpful? Give feedback.
-
The pins are pretty much dependent on the processor. For the ESP32 they are usually as described in the README. But you can redefine pretty much all pins: Just make sure that you also define any custom cs pin in the constructor of AudioSourceSDFAT. It is also processor dependent how to define the custom SPI pins. On the ESP32 this can be done with the begin(int8_t sck = -1, int8_t miso = -1, int8_t mosi = -1, int8_t ss = -1) method. |
Beta Was this translation helpful? Give feedback.
-
Awesome thanks @pschatzmann |
Beta Was this translation helpful? Give feedback.
The pins are pretty much dependent on the processor. For the ESP32 they are usually as described in the README.
As far as I can see, this is consistent with this tutorial
But you can redefine pretty much all pins: Just make sure that you also define any custom cs pin in the constructor of AudioSourceSDFAT.
It is also processor dependent how to define the custom SPI pins. On the ESP32 this can be done with the begin(int8_t sck = -1, int8_t miso = -1, int8_t mosi = -1, int8_t ss = -1) method.