0

I am switching a code from Arduino Uno R3 to Arduino Uno R4 Wifi due to the limitation of RAM spaces on R3. I use a thermocouple shield and SD Card read/write shield with the project, which requires me to transfer between mode 3 and mode 0 on R3. However, when I try to do the following code on R4:

SPI.setDataMode(SPI_MODE3); 

The IDE told me that SPI does not have a function named setDataMode. I tried to run the program without using setDataMode, but it does not seem work correctly (SD Cards with empty data).

Compilation error: 'class arduino::ArduinoSPI' has no member named 'setDataMode'

Thank you all for helping. the issue is resolve by using SPISettings variable along with SPI.beginTransaction(SPISettings) and SPI.endTransaction(SPISettings)

Bh4
  • 3
  • 2

1 Answers1

0

I looked at SPI.h in the R4 core here: https://github.com/arduino/ArduinoCore-renesas/blob/main/libraries/SPI/SPI.h

It looks like you have to set up a configuration struct and pass to a different function:

arduino::SPISettings const DEFAULT_SPI_SETTINGS = arduino::SPISettings(1000000, MSBFIRST, arduino::SPI_MODE0);
    arduino::SPISettings _settings = arduino::SPISettings(0, MSBFIRST, arduino::SPI_MODE0);

Then in beginTransaction you have the opportunity to pass in those settings:

virtual void beginTransaction(arduino::SPISettings settings);

I'm not 100% sure how that all works, but at least this should get you going in the right direction.

Delta_G
  • 3,391
  • 2
  • 13
  • 24