I'll go straight to the problem:
I tried to use a Sd card for data logging but weird things started to happen. At first the card was detected properly and everything seem to go well. Then, at some point, I was not able to write or read from it. Furthermore, strange files* were being created when the code was executed (the code I'm talking about is the most basic code you can imagine to just open a file, write a word on it and then close the file, that's it), files that I could not delete from the SD unless I formatted it. The card is a 32 gb ones and I thought that there could be a problem with that, and here comes another point of confusion for me: I tried a 2gb one that I had from an old camera and all worked fine (same circuit, same board, same program). The thing is that I have read that 32gb is perfectly handle by the board so I don't know what to take from this.
I also have to say that I tested the card with the code on the examples tab and it detected the card and everything seem to be just fine (I checked the free memory to confirm that it matched the "expect" value and it did), although it works erratically. On top of that, I tested the card on a camera to see if anything weird happened and everything went fine.
*Those strange files were folders and other files that had non-valid names that the computer couldn't handle in any way.
On top of all that, I also tried changing the module and the board (both time atmega models) and the results were the same.
I have tried everything that came to mind and everything I read online that was related to this and nothing worked.
Hope someone more experienced than me on this could help me out. If you need any more information that I can provide that I forgot now or that I don't know that could help ask for it and I'll gladly provide it.
Thank you for your time (and most likely your patience).
tried the module and the same SD card (32gb) with an Uno and it worked perfectly. Tried a micro sd module on the previous board (Mega2560) and it worked fine.
If this is full-size SD, I'd like to see a picture of the SD module. Most full-size SD modules from the Far East feed 5V to the CLK, CS and MOSI pins instead of the proper 3.3V. Some cards can deal with that, but some can't.
Also, I think the 32GB card needs to be SDHC, not SDXC.
Yeah, that module is appropriate for use with a 3.3V processor, but not for 5V. The regulator on the module supplies 3.3V to power the SD card, but the processor's three SPI output lines (MOSI, CLK and CS) are sent at 5V, which will exceed the absolute maximum ratings for most cards. That said, this module has been sold as working with 5V processors for years, and it seems to work for a lot of cards. Here's an SD module that appears to do it right:
I can't guarantee that this is the cause of your problem. But in case you want to try it, I'll attach a fix that might let you use the module you have, but you may have to slow things down for it to work correctly.