SD.end() not provided -- How to release SPI bus after accessing SD card? #404
Replies: 2 comments
-
The SD library has end() since 2017. But it has a different meaning than what you're expecting...
Why would you think that? Take a look at Sd2Card.cpp and search for HTH, |
Beta Was this translation helpful? Give feedback.
-
Thank you Flössie for this information. I'll take a look at Sd2Card.cpp. I had assumed that I might foul SD library operation if I was to use SPI commands on the same SPI bus. Good to know that that is not an issue. Paul |
Beta Was this translation helpful? Give feedback.
-
Maybe I should ask this on the Arduino forum, since it’s probably a question that doesn’t apply only to the DxCore. But people here are super knowledgeable, so I thought I would ask here.
First, a little background about my application. I’m using an SD card on a homebrew AVR128DB64 board using Spence’s DxCore. The board is currently running at 5V and I’m using CD74HC4050 level converters so the card sees 3.3V signals; not using MVIO in this case, but will do so in the next board Rev. The SPI port is PG4-PG7 [SPI.swap(SPI0_SWAP_ALT2)].
I’m reading audio voice files from the SD card that are encoded in old Bell Labs uLaw 8 bit PCM coding at 8000 samples per second. The samples are converted in software from the companded 8 bit PCM format to 14 bit linear and the 14 linear data are sent to the DAC (losing the 4 LSB bits in the process). The resulting audio output sounds pretty good, even with just a 10 bit DAC.
All that’s background, and not really relevant to my question, but at least you now know the application.
My question is, once my program runs “SD.begin(cs-pin)” the SD library never seems to release the SPI bus. There is no “SD.end()” command. So if I wanted to use the SPI bus to access some other peripheral, after accessing the SD card, do I just use the SPI library and assume I won’t mess up something for the next time the SD card is accessed via the SD library? (and of course I'd ensure that only the correct chip select is asserted at the right times).
Beta Was this translation helpful? Give feedback.
All reactions