Attiny 1634 with microSD card libraries

Hi!
I am using ATTINY 1634 due it its small size and relatively high pin count. I was hoping to save some data on a microSD card.
When I load the SD.h library, I get a number of errors that ports or pins were not defined in the scope (e.g. DDRB, PIN0, PORT0 etc.). I tried to use the SdFat.h library, which does not give me there results, but instead cannot support the SoftSpi on this board (or at least that's how I understand the error).

Long story short - is there a way to get ATTINY 1634 working to save to microSD card? Is there an alternative board I can choose of similar size and pin count that will work?

thank you for the help!

You might find this resource helpful:

https://elm-chan.org/fsw/ff/00index_p.html

Are they a secret?

Please read and use this link: How to get the best out of this forum - Development Tools / IDE 1.x - Arduino Forum

It's a long list of errors like:

c:\Users\AK125843\Documents\Arduino\libraries\SD\src/utility/Sd2PinMap.h:441:5: note: suggested alternative: 'DDRB'
   {&DDRD, &PIND, &PORTD, 0},  // D0  0
     ^~~~
     DDRB

except they refer to DDRd, PIND and PORTD, and repeat. Basically, I get an error for each of the three items in the bracket, and that for each number (0 to 7, here an example with 5): {&DDRD, &PIND, &PORTD, 5}, // D5 5

I use SD.h library version 1.3.0 and have IDE 2.3.5 with ATTinyCore 1.5.2, if that helps.

The issue you’re seeing comes from the fact that most Arduino SD libraries (like SD.h) were written with the classic ATmega chips in mind, so they expect the familiar AVR I/O register names (DDRB, PORTB, etc.). On the ATtiny1634, those registers and pin definitions are different, which is why the compiler throws errors.

SdFat is usually the better option since it’s more actively maintained, but as you noticed, it doesn’t support software SPI on that chip out of the box. To get things working you have a few paths:

  • Use hardware SPI: The ATtiny1634 does have an SPI peripheral (on pins PA4 = SS, PA5 = MOSI, PA6 = MISO, PA7 = SCK). If you can wire your microSD to those pins and initialize SdFat with them, you stand a much better chance.
  • Check for core/variant support: Make sure you’re using an Arduino core that properly defines the 1634 registers. Spence Konde’s ATTinyCore has good support for many Tinys, and often helps with library compatibility.
  • Library tweaks: If you really need SoftSPI, you’d have to patch SdFat to recognize the ATtiny1634. That means editing the low-level pin mapping, which can be a bit of work.

If switching hardware is an option, you might find it easier with an ATmega328PB (small TQFP package, more pins than the classic 328P, fully supported by SdFat) or an ATmega32U4 (used in the Pro Micro, also compact but has native USB). Both have better library compatibility and are only slightly larger.

So yes, it’s possible on the 1634 if you stick to hardware SPI and the right core, but if you want less friction, one of the small ATmega chips might save time.

Thank you! It's what I thought, I'm not a pro so it takes time to figure all this out; you've helped me a lot.