-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add SD card library #114
Comments
Has anyone tried it? I haven't. |
What fails with it? My initial attempt would be to take that one, and in Sd2PinMap.h find the line
and change it to
then see where it next starts complaining. |
Can antone wirth hardware handy install this one in place of the normal one and see what doesn't work? |
I was able to get this working fine for my purposes. Basically did what @SpenceKonde suggested above. Changes are at SpenceKonde/SD@master...nabelekt:get-working-for-DA128DA28. Compiles and runs fine on the DA128DA28 with the chipSelect pin set to 7. |
I also use the modified library just fine on a AVR128DB48 with SD on PF2. |
The chip select pin shouldn't make a difference - I'm referring to the pinswaps to get the alternate sck/miso/mosi pins. I think one would need to set SPI.swap(1); before the call to SPI.begin() is made. |
Can anyone confirm whetherthis works after swapping to an alternate pinset using SPI.swap(non-zero)? That is the thing I' am ionly 90% sure of. Ince that's confirmed, I'm gonna try to get Arduino to merge it in. |
we need a test done with SPI.swap(SPI1_SWAP1); (SPI1 with alternate pin mapping, using the PC4~PC6 lines on a 48+ pin part). If that doesn't work, the next step would be to see whether it's the alternate port (SPI1 vs 0) that broke it, or the alternate pinset, or if either of them will break it, SPI.swap(SPI0_SWAP_1); puts the SPI port onto PE0-PE2) on a 48+ pin DA/DB, while SPI.swap(SPI1_SWAP_0) puts it on PC0~2. |
I can try this on a DB64. I'll report back in a day or two. |
Here are some results of my SPI testing this afternoon. I'm using a homebrew DB64 and an SD card module jumpered into the DB64's SPI0 standard pins (PA4, PA5 and PA6). Not that it matters but I'm using PA3 as chip select. I'm also doing serial download (not UPDI) on DxCore 1.4.4. I'm running this sketch: https://www.arduino.cc/en/Tutorial/LibraryExamples/CardInfo With a In file included from sketch\DB64-sd-card-info-220102-01.ino.cpp:1:0: And I changed the chip select define to be: The rest of the sketch is as per the website reference. When I run the program with the SD module attached to PA4-PA5-PA6 (cs on PA3) all looks good. All the output on the console about about blocks, cluster sizes and volumes looks good. However I don't get a list of the four text files that are on the SD card. Not sure why that's missing. I then put a I recompile, serial download, and then my Serial Monitor just shows jumbled characters, with a lot of backwards ? marks, like the serial baud rate is now wrong. So it looks like SPI.swap(1) causes problems for serial. If I change the argument of the SPI.swap function from 1 to 0 [ SPI.swap(0) ] then the serial output works correctly again. |
Well this is embarrassing. Of course SPI.swap(1) kills serial on my test board. I'm using PE0 PE1 pins for my console terminal (UART4 primary) and PE0 PE1 are part of the pinset for SPI0 alternate. Let me try some other SPI alternatives that are not going to interfere with other things on my board. |
Ok, good news! I've tested all the SPI swap possibilities (based on the table below) on the DB64 and they all appear to work correctly. Here's the table from: https://github.com/SpenceKonde/DxCore/blob/master/megaavr/libraries/SPI/README.md
Here are the statements I used to select the particular pins to use for SPI given the argument of the swap statement: //SPI.swap(SPI0_SWAP_DEFAULT); // this works: SPI on PA4 PA5 PA6 Of course, only one of these statements would be uncommented for a particular test (read info from SD card). In the case of SPI0_SWAP_ALT1 which uses PE0, PE1, PE2 (and clobbered my Serial4 console in my initial test)...for that test I changed the solder bridging jumpers on my board to make Serial3 (PB0, PB1) my console and reburned the bootloader accordingly. With the console serial port off PE0 and PE1, then the SPI port with SPI.swap(SPI0_SWAP_ALT1) worked as it should. So, bottom line, it looks to me like all the possible SPI swap positions for the DB64 work correctly. Also, I i didn't mention it before, but I modified Sd2PinMap.h as Spence suggested to change #elif defined(AVR_ATmega4809) // Arduino UNO WiFI Rev2 follows to #elif (AVR_ARCH == 102 || AVR_ARCH == 103 || AVR_ARCH == 104) |
Wonderful, thank you! I will PR this back to the official library repo. |
Gears are turning on that PR, |
Unless the PR is rejected, there will be no changes made to DxCore and megaTinyCore will get it's copy of SD removed. |
I am just wondering if a DxCore-compatible library which allows reading and writing to an SD card will be available, just like the Arduino one (https://github.com/arduino-libraries/SD).
The text was updated successfully, but these errors were encountered: