Problem with SPI

Hello,

I am trying to use the following library with Arduino Nano Every.

It is a library for CC1101 RF modules.

While compiling there is a an issue that i don't understand.

'SPCR' was not declared in this scope
'SPDR' was not declared in this scope
'SPE' was not declared in this scope

As far as i came to know it is related to SPI.

Could you please give me some hint of how to solve these issues ?

I am using Arduino IDE 1.8.10

Thanks for your help

K.

It could be a problem with your code.

Hello,

It is a problem in the library itself.

See the extract of the cpp file :

/****************************************************************
*FUNCTION NAME:SpiInit
*FUNCTION     :spi communication initialization
*INPUT        :none
*OUTPUT       :none
****************************************************************/
void ELECHOUSE_CC1101::SpiInit(void)
{
  // initialize the SPI pins
  pinMode(SCK_PIN, OUTPUT);
  pinMode(MOSI_PIN, OUTPUT);
  pinMode(MISO_PIN, INPUT);
  pinMode(SS_PIN, OUTPUT);

  // enable SPI Master, MSB, SPI mode 0, FOSC/4
  SpiMode(0);
}
/****************************************************************
*FUNCTION NAME:SpiMode
*FUNCTION     :set spi mode
*INPUT        :        config               mode
			   (0<<CPOL) | (0 << CPHA)		 0
			   (0<<CPOL) | (1 << CPHA)		 1
			   (1<<CPOL) | (0 << CPHA)		 2
			   (1<<CPOL) | (1 << CPHA)		 3
*OUTPUT       :none
****************************************************************/
void ELECHOUSE_CC1101::SpiMode(byte config)
{
  byte tmp;

  // enable SPI master with configuration byte specified
  SPCR = 0;
  SPCR = (config & 0x7F) | (1<<SPE) | (1<<MSTR);
  tmp = SPSR;
  tmp = SPDR;
}

I can’t find where they (SPCR, SPDR…) are declared !

Is this something related to SPI ?

Thanks for your help

K.

Does it compile OK for a regular Nano/Uno but gives the error with Nano Every?

If so, the library needs updating to make it compatible with Nano Every.

Take a look at this issue raised on GitHub against that library. Someone is complaining about similar errors with Arduino Zero and esp8266. The author has not responded after 3 years, so I don’t think they ever will. Maybe look for a fork of the library which had been fixed by someone else, or a completely different library.

Hello,

Thanks for your hints.

The code compiles for Arduino Nano.

So there is an issue with the Arduino Nano Every.

I will try to find out some fork.

Thanks for your help.

Regards,

K.

AFAIK the word "nano" is the only thing in common between a regular nano and a nano every.

Life would have been much simpler if the Arduino folks had used a different name for their new product.

...R

Well, the Every is an 8-bit AVR running at 5V, and the form factor is similar to the original Nano, so they have that in common. But the chip is sufficiently different to atmega328 that code directly accessing hardware registers is unlikely to work.

The real problem here is that the original library is so old that perhaps the standard Arduino SPI library was not available or sufficiently developed, and the authors elected to skip that and access the atmega328 hardware registers directly. The author of the library, the version the OP is using, simply updated it for Arduino 1.0, but chose not to, or was unable to, update it to use the standard SPI library. This library needs updating to use the standard SPI library. Then it will be compatible with a much wider selection of “Arduino” boards. Perhaps someone has been good enough to do this already.