Hello,
I used the Arduino IDE 1.8.15 with megaavr package 1.8.7.
Now I found an error in interaction of Arduino IDE with Nano Every Board and avr-gcc 11.1.0. SPI does not work. The registers are configured wrong.
With original Arduino IDE avr-gcc Toolchain 7.3.0 and 10.3.0 SPI works.
Also the configuration from Arduino IDE with avr-gcc 11.1.0 and MCUdude MegaCoreX Package package works.
Which tells me that it can't be the avr-gcc 11.1.0 toolchain alone.
There must be a problem between SPI Lib and avr-gcc 11.1.0.
I don't get any error messages when compiling, related to SPI.
By the way SPI with avr-gcc 11.1.0 works with the Arduino Mega2560 without problems.
Except for those of the USART Lib.
C:\Arduino IDE Portable\megaAVR0\arduino-1.8.15\portable\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/UART.h: In member function 'virtual void UartClass::begin(long unsigned int)':
C:\Arduino IDE Portable\megaAVR0\arduino-1.8.15\portable\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/UART.h:98:49: error: bitwise operation between different enumeration types 'USART_CMODE_enum' and 'USART_CHSIZE_enum' is deprecated [-Werror=deprecated-enum-enum-conversion]
98 | #define SERIAL_8N1 (USART_CMODE_ASYNCHRONOUS_gc | USART_CHSIZE_8BIT_gc | USART_PMODE_DISABLED_gc | USART_SBMODE_1BIT_gc)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
C:\Arduino IDE Portable\megaAVR0\arduino-1.8.15\portable\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/UART.h:156:50: note: in expansion of macro 'SERIAL_8N1'
156 | void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
| ^~~~~~~~~~
cc1plus.exe: all warnings being treated as errors
Changed to ... works for now.
//#define SERIAL_8N1 (USART_CMODE_ASYNCHRONOUS_gc | USART_CHSIZE_8BIT_gc | USART_PMODE_DISABLED_gc | USART_SBMODE_1BIT_gc)
constexpr uint8_t SERIAL_8N1 { (static_cast<uint8_t>(USART_CMODE_ASYNCHRONOUS_gc) | USART_CHSIZE_8BIT_gc | USART_PMODE_DISABLED_gc | USART_SBMODE_1BIT_gc) };
Now the question is, if there are no errors in the bit definitions, which registers does the compiled code describe? So it can't be the SPI registers? Something is going completely wrong without being seen. SPI0.CTRLA is not configured and CLRLB completely different.
In addition to the problem, I can not switch a pin. In that case any pin as Salve Select does not go High.
I compared the controller header files of the toolchains. Nothing has changed between 10.3 and 11.1.
What could be the problem?
What else can I do?
My test sketch.
#include<utilities.h>
#include <SPI.h>
void setup()
{
Serial.begin(250000);
Serial.println(F("\nµC Reset #### #### ####"));
SPI.begin();
showRegister();
// avr-gcc 11.1.0: SPI0 CTRLA: 0b0000'0000, CTRLB: 0b0000'0001
// avr-gcc 10.3.0: SPI0 CTRLA: 0b0010'0001, CTRLB: 0b0000'0100
// avr-gcc 7.3.0: SPI0 CTRLA: 0b0010'0001, CTRLB: 0b0000'0100
}
void loop()
{ }
void showRegister (void)
{
Serial.print(F("SPI0 CTRLA: ")); formatBINln(Serial, SPI0.CTRLA, true);
Serial.print(F("SPI0 CTRLB: ")); formatBINln(Serial, SPI0.CTRLB, true);
Serial.print(F("SPI0 INTCTRL: ")); formatBINln(Serial, SPI0.INTCTRL, true);
Serial.print(F("SPI0 INTFLAGS: ")); formatBINln(Serial, SPI0.INTFLAGS, true);
Serial.print(F("SPI0 DATA: ")); formatBINln(Serial, SPI0.DATA, true);
}
utilities.zip (15,9 KB)