-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sd.begin(SPI_CONFIG) breaks my DMA ADC datalogger on the SAMD51 #483
Comments
I can't help with Adafruit's SAMD51 DMA. I tried to use it in one of my apps and gave up. I suggest you use the Adafruit port of SdFat and post issues with Adafruit. I was going publish fast examples using Adafruit's DMA for SAMD but decided it was too flaky. |
Hey Greiman, That makes sense. It has been tricky. I started with the Adafruit Fork of SdFat, but I was trying to achieve high write speeds to keep up with my datalogging ADCs and I don't think the Adafruit Fork supports the SAMD51 DMA based SPI transfers. I used this example to get my high write speeds. I was able to replicate it with the normal SdFat library: #434 I was just curious if you knew anything about which registers the begin() method uses so that I could identify any conflicts in my DMA datalogger. I can't find the root begin() anywhere. |
I don't remember details about the SAMD driver. Looks like Adafruit's SdFat is far behind the current SdFat and has no option to use their DMA SPI driver. |
@greiman Is there anything in SdFat specifically when sd.begin(SD_CONFIG) is called that would enable the DMAC on a M4. Does SdFat have ZeroDMA as a dependency and if so where is that called in the library? I have done some testing with regard to the code above and found some interesting issue. I reconfigured the code write out the DMA controller and channel registers and added #define DEBUG_SD_BEGIN where I can easily configure if sd.begin is called or not. When sd.begin is not called (#define DEBUG_SD_BEGIN 0), the DMA runs normally and GPIO 10 and 11 (when on Grand Central board) pulse for 3us with a period of ~850 us indicating that the buffers are being filled and all of the DMA channels are sequencing properly (you can also see this in the registers that are printed). When sd.begin is called (#define DEBUG_SD_BEGIN 1), there is no pulsing on either GPIO. The registers indicate that something has changed the DMAC BASEADDR and WRB but none of the channel descriptor addresses. This causes CH2 (previously CH5) to throw a transfer error and suspend flag from the memory misalignment and halts the rest of the DMA sequence. Below is the code and serial monitor output which shows the error. (This error persists no matter if Spi_array_transfer 0 or 3 is used)
|
SdFat does not know about DMA. It may cause DMA to be used if the SPI library is implemented with DMA. SdFat only calls SPI.begin() with no arguments, SPI.beginTransaction(), SPI.transfer(), SPI.endTransaction() and possibly SPI.end() if sd.end() is called. SdFat supports three SPI transfer signatures:
Use of array transfers requires editing SdFatConfig here. |
Hi @raider-snake, just commenting to see if you found any solutions yet or if greiman's solution above helped you. I'm working on something pretty similar on a Feather M4 Express + Datalogger Featherwing and would appreciate any updates you may have! |
``I have a data logger that takes in inputs from 2 ADCs and writes them to 2 circular buffers using DMA. This part works well. I am able to read data in and get it to the buffers at about 2.4 Mb/s.
The issue I was running into was how to store it. I eventually figured out how to use SdFat with the SPI configuration that utilizes adafruit's zeroDMA library to handle the SD card writes. I was able to write buffers to the SD card at about 2.7 Mb/s in my stand alone test code. This should be fast enough to keep up with the DMA data logger.
The issues arose when I tried to combine the two. Have data incoming over DMA get written to the SD card. The DMA initialization and setup all works perfectly until sd.begin(SD_CONFIG) is called. I am not sure what is going wrong or what is conflicting in the SdFat library with my DMA logger.
Any help would be great.
The text was updated successfully, but these errors were encountered: