Closed Oxmaster closed 3 years ago
I don't have this hardware so you must solve this problem.
As per (https://github.com/dbuezas/lgt8fx/issues/24)
The SPI of LGT8F328P has more features than ATmega328P SPI. One of these features is 4 byte input and 4 byte output buffer. (Translated databook v1.0.5 page 195: -Input/output both have 4 buffer register.) If your SD card library not handling this buffer, SPI will not work as expected. Maybe your SD card library could use the SPI library from this lgt8f package. But if your SD card library use hardware SPI, it won't work.
For SdFat v1.x (I haven't played with the 2.x series), In SdFarConfig.h (Arduino/libraries/sdfat), set:
#define USE_STANDARD_SPI_LIBRARY 1
As per the comments:
* If the symbol USE_STANDARD_SPI_LIBRARY is zero, an optimized custom SPI
* driver is used if it exists. If the symbol USE_STANDARD_SPI_LIBRARY is
* one, the standard Arduino SPI.h library is used with SPI. If the symbol
* USE_STANDARD_SPI_LIBRARY is two, the SPI port can be selected with the
* constructors SdFat(SPIClass* spiPort) and SdFatEX(SPIClass* spiPort).
... works great then. Software SPI also works (see the rest of the comments and examples included w/SdFat)
I am no longer adding custom drivers. There are now hundreds of "Arduino like boards".
SdFat version 2.x probably will fail with a compile error for LGT8F328P if USE_STANDARD_SPI_LIBRARY is zero.
I'm checking out the ATmega 328 clones by Logic Green (LGT8Fx). There is some support as these chips are not well known (https://github.com/dbuezas/lgt8fx). I have the 328P-SSOP20 (pro mini clone) and 328P-LQFP32 (nano clone) Beforehand I tested the SD card and the library with Arduino Nano clone (328P-MU QFN32 with CH340G) and everything works. Also tested the standard SD card library that comes with Arduino IDE, and it works on Nano and on the LGT8Fx clones. I'd like to help to make this library support the LGT8Fx chips but I don't know too much about this low level stuff that it implies, but can do some tests and relay the results. Here is SdInfo output from 328P-MU Nano at 16 MHz, the card was formated via the SdFormatter sketch.
At 32 MHz from SdInfo sketch:
And at 16 MHz (same for 8 MHz):
There is something strange with OEM ID and Product.
Also tested SoftwareSPI sketch and it works at any clock speed.
I'm unsure if it's hardware or software issue.