I am trying to load an old project on an Arduino Nano board. This time on Nano board is installed an ATmega328Pb so I added this line to the platformioini “ board_build.mcu = atmega328pb “ as I have done in the past. The result is the following:
Compiling .pio\build\nanoatmega328\FrameworkArduino\HardwareSerial2.cpp.o
In file included from lib\NRF24L01\RF24_config.h:110:0,
from lib\NRF24L01\RF24.cpp:10:
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::beginTransaction(SPISettings)':
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:203:5: error: 'SPCR' was not declared in this scope
SPCR = settings.spcr;
^~~~
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:203:5: note: suggested alternative: 'SPCR0'
SPCR = settings.spcr;
^~~~
SPCR0
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:204:5: error: 'SPSR' was not declared in this scope
SPSR = settings.spsr;
^~~~
In file included from lib\NRF24L01/RF24_config.h:110:0,
from lib\NRF24L01/RF24.h:18,
from src\main.cpp:2:
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::beginTransaction(SPISettings)':
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:203:5: error: 'SPCR' was not declared in this scope
SPCR = settings.spcr;
^~~~
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:204:5: note: suggested alternative: 'SPSR0'
SPSR = settings.spsr;
^~~~
SPSR0
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h: In static member function 'static uint8_t SPIClass::transfer(uint8_t)':
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:209:5: error: 'SPDR' was not declared in this scope
SPDR = data;
^~~~
In file included from C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src\SPI.cpp:14:0:
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src\SPI.h: In static member function 'static void SPIClass::beginTransaction(SPISettings)':
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src\SPI.h:203:5: error: 'SPCR' was not declared in this scope
SPCR = settings.spcr;
^~~~
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:209:5: note: suggested alternative: 'SPDR0'
SPDR = data;
I have cut the most of the message in the middle because the error is the same.
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src\SPI.h:298:5: error: 'SPCR' was not declared in this scope
SPCR = (SPCR & ~SPI_MODE_MASK) | dataMode;
XCLOCK_MASK) | ((clockDiv >> 2) & SPI_2XCLOCK_MASK);
^~~~
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:304:5: note: suggested alternative: 'SPSR0'
SPSR = (SPSR & ~SPI_2XCLOCK_MASK) | ((clockDiv >> 2) & SPI_2XCLOCK_MASK);
^~~~
SPSR0
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::attachInterrupt()':
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:309:42: error: 'SPCR' was not declared in this scope
inline static void attachInterrupt() { SPCR |= _BV(SPIE); }
^~~~
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:309:42: note: suggested alternative: 'SPCR0'
inline static void attachInterrupt() { SPCR |= _BV(SPIE); }
^~~~
SPCR0
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::detachInterrupt()':
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:310:42: error: 'SPCR' was not declared in this scope
inline static void detachInterrupt() { SPCR &= ~_BV(SPIE); }
^~~~
C:\Users\gsrad\.platformio\packages\framework-arduino-avr\libraries\SPI\src/SPI.h:310:42: note: suggested alternative: 'SPCR0'
inline static void detachInterrupt() { SPCR &= ~_BV(SPIE); }
^~~~
SPCR0
*** [.pio\build\nanoatmega328\src\main.cpp.o] Error 1
*** [.pio\build\nanoatmega328\lib6ef\NRF24L01\RF24.cpp.o] Error 1
========================================================================== [FAILED] Took 1.12 seconds ======================================================================
Just commenting out the line “board_build.mcu = atmega328pb “ the result is:
#Linking .pio\build\nanoatmega328\firmware.elf
Checking size .pio\build\nanoatmega328\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 10.9% (used 223 bytes from 2048 bytes)
Flash: [= ] 12.9% (used 3952 bytes from 30720 bytes)
Building .pio\build\nanoatmega328\firmware.hex
========================================================================== [SUCCESS] Took 2.54 seconds =======================================================================