Moving Adafruit Clue nrf52840 over to PlatformIO getting errors in Adafruit_ZeroTimer

I’m missing definitions for several items required by ZeroTimer like:
TC_CTRLA_PRESCALER
TC_CTRLA_MODE_COUNT8
TC_CTRLA_MODE_COUNT16
PIN_PA18E_TC3_WO0
MUX_PA19E_TC3_WO1 and several others.
I’ve even tried to locate these in the Arduino IDE but I’m stumped. I’m thinking these are defined in board definitions. Can someone point me in the right direction to find these?

Thanks in advance!

Please upload the exact PlatformIO project that doesn’t compile so we don’t have to do guesswork.

Here is the content of the platformio.ini file:

[env:adafruit_clue_nrf52840]
platform = nordicnrf52
board = adafruit_clue_nrf52840
framework = arduino
lib_deps =
     adafruit/Adafruit Arcada Library@^2.5.4
     adafruit/Adafruit ImageReader Library@^2.9.0
     adafruit/Adafruit FreeTouch Library@^1.1.1
     adafruit/Adafruit TouchScreen@^1.1.3
     adafruit/Adafruit GFX Library@^1.11.5
     adafruit/Adafruit ST7735 and ST7789 Library@^1.9.3
     adafruit/Adafruit BMP280 Library@^2.6.6
     adafruit/Adafruit ILI9341@^1.5.12

And with which source code can I reproduce the error?

I created a new project and started adding till the problem reoccurred. This time compiling just the empty main.cpp:

#include <Arduino.h>
#include "wire.h"
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}

I want to run the display on the Clue so I added Adafruit_Arcada_Library to lib_deps. I was getting errors so I started adding the list of libraries suggested from adafruit at the following link:

I finally got rid of the wire.h error by including it in main.cpp and now the errors previously mentioned have shown up. These are definitions needed in the Adafruit_ZeroTimer and Adafruit_ImageReader_EPD. The platformio.ini for this project ended up being the following:

[env:adafruit_clue_nrf52840]
platform = nordicnrf52
board = adafruit_clue_nrf52840
framework = arduino
lib_deps =
adafruit/Adafruit Arcada Library@^2.5.4
adafruit/Adafruit GFX Library@^1.11.5
adafruit/Adafruit BusIO@^1.14.1
adafruit/Adafruit NeoPixel@^1.10.7
adafruit/Adafruit SPIFlash@^4.0.0
adafruit/Adafruit FreeTouch Library@^1.1.1
adafruit/Adafruit TouchScreen@^1.1.3
adafruit/Adafruit Zero DMA Library@^1.1.1
adafruit/Adafruit ST7735 and ST7789 Library@^1.9.3
adafruit/Adafruit ILI9341@^1.5.12
adafruit/Adafruit LIS3DH@^1.2.4
adafruit/Adafruit Unified Sensor@^1.1.7
adafruit/Adafruit ImageReader Library@^2.9.0
bblanchon/ArduinoJson@^6.20.0
adafruit/Adafruit ZeroTimer Library@^2.2.2
adafruit/Adafruit TinyUSB Library@^1.18.1
adafruit/Adafruit WavePlayer Library@^1.0.4
adafruit/SdFat - Adafruit Fork@^2.2.1
paulstoffregen/OneWire@^2.3.7

How is this library going to work for a nRF52840 when it was explicitly made for a Atmel SAMD21 chip?

Which library has a hard dependency on Adafruit ZeroTimer? Because the Arcadia library correctly does

#if defined(_SAMD21_) || defined(__SAMD51__)
#include <Adafruit_ZeroTimer.h>
#endif

so there’s no need to include this library at all for your microprocessor…

Incompatible libraries like these can be weeded out by setting lib_compat mode to strict. Additionally it can help to set the lib_ldf_mode to something like chain+ so that conditional includes are always correctly evaluated.

Another problem that arises then in compilation (and after additionall adding the needed Adafruit EPD and Adafruit LSM6DS libraries) is that the unconditionally needed “Adafruit WavePlayer” library declares SAMD only compatibility when it is in fact compilable for other platforms…

So I just forked that library and set it to *

and put it in the platformio.ini accordingly. Finally, I placed a #include <Adafruit_Arcada.h> in the src/main.cpp so that PlatformIO will detect the libraries accordingly. PlatformIO has a quirk where libraries added in lib_deps but otherwise unreferenced in source code will not have their dependencies resolved.

And with that it compiles successfully.

Linking .pio\build\adafruit_clue_nrf52840\firmware.elf
Building .pio\build\adafruit_clue_nrf52840\firmware.hex
Checking size .pio\build\adafruit_clue_nrf52840\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   2.5% (used 6268 bytes from 248832 bytes)
Flash: [          ]   4.3% (used 35452 bytes from 815104 bytes)
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_Arcada.h>

void setup()
{
    // put your setup code here, to run once:
}
void loop()
{
    // put your main code here, to run repeatedly:
}
[env:adafruit_clue_nrf52840]
platform = nordicnrf52
board = adafruit_clue_nrf52840
framework = arduino
lib_ldf_mode = chain+
lib_compat_mode = strict
lib_deps =
    adafruit/Adafruit Arcada Library@^2.5.4
    adafruit/Adafruit GFX Library@^1.11.5
    adafruit/Adafruit BusIO@^1.14.1
    adafruit/Adafruit NeoPixel@^1.10.7
    adafruit/Adafruit SPIFlash@^4.0.0
    adafruit/Adafruit FreeTouch Library@^1.1.1
    adafruit/Adafruit TouchScreen@^1.1.3
    adafruit/Adafruit Zero DMA Library@^1.1.1
    adafruit/Adafruit ST7735 and ST7789 Library@^1.9.3
    adafruit/Adafruit ILI9341@^1.5.12
    adafruit/Adafruit LIS3DH@^1.2.4
    adafruit/Adafruit Unified Sensor@^1.1.7
    adafruit/Adafruit ImageReader Library@^2.9.0
    bblanchon/ArduinoJson@^6.20.0
    adafruit/Adafruit TinyUSB Library@^1.18.1
    adafruit/Adafruit WavePlayer Library@^1.0.4
    adafruit/SdFat - Adafruit Fork@^2.2.1
    paulstoffregen/OneWire@^2.3.7
    adafruit/Adafruit EPD@^4.5.1
    adafruit/Adafruit LSM6DS@^4.7.0
    https://github.com/maxgerhardt/Adafruit_WavePlayer/archive/refs/heads/master.zip 
    ;adafruit/Adafruit WavePlayer Library@^1.0.4 IS NOT USABLE BECAUSE OF SAMD REQUIREMENT IN LIBRARY.PROPERTIES

This issue is tracked in Incorrect "architectures" declaration in library.properties · Issue #3 · adafruit/Adafruit_WavePlayer · GitHub now btw.

Thank you maxgerhardt! I implemented your suggestions but for some reason still had problems with Wire.h. In another forum I found a fix for this in platformio.ini and simply added “Wire” into the lib_deps:
lib_deps =
adafruit/Adafruit Arcada Library@^2.5.4
adafruit/Adafruit GFX Library@^1.11.5
Wire
adafruit/Adafruit BusIO@^1.14.1
adafruit/Adafruit NeoPixel@^1.10.7

Thanks again for your detailed and very helpful response.

1 Like