How to replace AVR-like EEPROM functionality for SAMD21

you might miss the begins calls that are needed (?) with Sparkfun's library

in the setup() I would add

#ifndef __AVR__
  Wire.begin();
  if (! EEPROM.begin())  {
    Serial.println(F("Error: No external EEPROM detected."));
    while(true) yield() ;
  }
#endif

You are right.
But I didnt forget those in my sketch. I just didn't post them here :slight_smile:

PS: Whats the equivalent to


#ifdef __AVR__ 
for  SAMD21 ? Could it be 

#ifdef __SAMD21__   

?

good :wink:

These are the defines the IDE passes to avr-gcc and avr-g++ when compiling for an Uno:

-DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR

Clock speed, IDE version, board name, and processor architecture. Not sure where __AVR__ comes from, but the IDE uses ARDUINO_ARCH_AVR as its tag. You can get these from the compilation output.

Not sure which specific ARM board you're using, here's the tags for a Zero:

-DF_CPU=48000000L -DARDUINO=10813 -DARDUINO_SAMD_MKRZERO -DARDUINO_ARCH_SAMD -DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x804f -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino MKRZero\""

So the tag is the IDE uses is ARDUINO_ARCH_SAMD.

Thanks very much.
I use my own custom based board. Similar pin configuration as the arduino zero.

I have been using AVR and VARIANT_ARDUINO_ZERO so far and they seem to work

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