Attiny Series 1/2 SD Card

Hi all. I use an attiny 414 because it offers a true DAC (no PWM) for a low price (<1€ for 1000 pce). I cannot get any SD card library running on this MCU with the "MegaTinyCore" in Boards Manager. I tried SD.h, petit fat ... all are running on the Arduino Uno but not on the Attiny414. I tried the Attiny424 and Attiny 404, the code doesn´t compile. It compiles with Attinys from the Boards Manager File "AttinyCore", but they are not Series 1 or Series 2 with a true DAC.

It looks like the register definitions do not fit.

Do you know an alternative MCU with DAC and low price?
Is there a suitable SD Card library? FAT32 would be cool.

Thank you very much,
Holger

Actually as i installed the core specified, and compiled an example, it showed that the core comes with it's own SD.h, and that does not appear to compile at all for this board.

Best to ask @DrAzzy i figure.

The standard SD library is specifically rigged to dump the AVRxt parts other than the 4809 into the wrong bin. It is as though it was intentional. That's why I invlide a version of SD that works correctly.

That i noticed.

But when i installed the MegaTinYCore, a standard SD example like 'cardinfo' throws a whole bunch of errors when compiling for a 414, even though the correct SD.h (i suspect Arduino15\packages\megaTinyCore\hardware\megaavr\2.6.10\libraries\SD
Is the correct file.) is used.

c:/users/deva_/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: address 0x2952 of C:\Users\deva_\AppData\Local\Temp\arduino_build_341001/CardInfo.ino.elf section `.text' is not within region `text'
c:/users/deva_/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: C:\Users\deva_\AppData\Local\Temp\arduino_build_341001/CardInfo.ino.elf section `.rodata' will not fit in region `text'
c:/users/deva_/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: address 0x8041e6 of C:\Users\deva_\AppData\Local\Temp\arduino_build_341001/CardInfo.ino.elf section `.bss' is not within region `data'
c:/users/deva_/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: address 0x2952 of C:\Users\deva_\AppData\Local\Temp\arduino_build_341001/CardInfo.ino.elf section `.text' is not within region `text'
c:/users/deva_/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: address 0x8041e6 of C:\Users\deva_\AppData\Local\Temp\arduino_build_341001/CardInfo.ino.elf section `.bss' is not within region `data'

these are just the first few, i suspect there is some kind of cascading effect, and you can probably reproduce that anyway.

Or is there some other file that is not included correctly ?

I assume that the 256 byte buffer allocated by the SD support would be a problem on chips with 128-256 bytes total RAM. :slightly_smiling_face:

Hi, I am still working on this problem. I found that only the SD.h works without errors.

I am using a Attiny1614 now because of the memory. I test my software with an Arduino Uno in parallel. There are separate SD.h libraries for both MCUs. I read data using the following code:

#include <SPI.h>
#include <SD.h>
File myFile;
const unsigned int FrameSize=512;
byte Data1[FrameSize];
(…)
SD.begin(7);
Filename="01/1.WAV"; //WAV-file with 44 Bytes header
myFile = SD.open(Filename);
myFile.read(Data1, FrameSize);

With the Arduino Uno I can read any data, it is always correct.

Attiny:
With the Attiny1614 it is different: The first 512 Bytes of data are read from the SD-Card without problems. The data is correct. If I want to read further data, nothing works any more.
I monitor the MOSI and the MISO Signal of the SD-Card SPI with a Scope. I see, that the SPI is inactive during the operation “myFile.read(Data1,FrameSize);”. The MCU seems to have read all 512 Bytes during “myFile = SD.open(Filename);”, here the SPI is active.
I do the same measurement with the Arduino Uno and I see an active SPI during read() operations. The Uno reads more data than 512 Bytes.
All Libraries are updated. The SD-Card and the wav-file are OK, it can be read by the Arduino Uno without problems.
Are there any known bugs with the SD.h-Library for Attiny Generation 1? Has it ever been tested with more than 512 bytes? Or is there running example code?
Thank you very much!

The SD.h library for the ATTiny1614 should have some example sketches showing how to use the library. You might try running some of them to see if your wiring is working ok.

But the fact that the first read works on both MCU suggests the wiring is ok, but something is going wrong in your software, or the library, on the second read of the 1614. I don't know if any special procedures are required for the ATTinys, but I would think the example sketches would show that.

Your code doesn't show how you read the second block. Could you post a compete sketch that does the two reads correctly on the Uno, but the second one fails on the ATTiny?

Hi, I found my mistake, thank you for trying to help me.
It was something with my hardware.
Thanks for your time.
Best regards,
Holger

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.