This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432P401R: SPI COMMUNICATION ERROR

Part Number: MSP432P401R

Hi, i am using ADAFRUIT'S MAX31865 with my MSP432...i try to use SPI and i get this error when i try to compile...

C:\Users\Gio\Desktop\energia-1.8.7E21\libraries\Adafruit-MAX31865-library\Adafruit_MAX31865.cpp:27:8: error: 'SPISettings' does not name a type

 static SPISettings max31865_spisettings = SPISettings(500000, MSBFIRST, SPI_MODE1);

        ^~~~~~~~~~~

C:\Users\Gio\Desktop\energia-1.8.7E21\libraries\Adafruit-MAX31865-library\Adafruit_MAX31865.cpp: In member function 'void Adafruit_MAX31865::readRegisterN(uint8_t, uint8_t*, uint8_t)':

C:\Users\Gio\Desktop\energia-1.8.7E21\libraries\Adafruit-MAX31865-library\Adafruit_MAX31865.cpp:199:9: error: 'class SPIClass' has no member named 'beginTransaction'; did you mean 'transaction'?

     SPI.beginTransaction(max31865_spisettings);

         ^~~~~~~~~~~~~~~~

C:\Users\Gio\Desktop\energia-1.8.7E21\libraries\Adafruit-MAX31865-library\Adafruit_MAX31865.cpp:199:26: error: 'max31865_spisettings' was not declared in this scope

     SPI.beginTransaction(max31865_spisettings);

                          ^~~~~~~~~~~~~~~~~~~~

C:\Users\Gio\Desktop\energia-1.8.7E21\libraries\Adafruit-MAX31865-library\Adafruit_MAX31865.cpp:216:9: error: 'class SPIClass' has no member named 'endTransaction'; did you mean 'transaction'?

     SPI.endTransaction();

         ^~~~~~~~~~~~~~

C:\Users\Gio\Desktop\energia-1.8.7E21\libraries\Adafruit-MAX31865-library\Adafruit_MAX31865.cpp: In member function 'void Adafruit_MAX31865::writeRegister8(uint8_t, uint8_t)':

C:\Users\Gio\Desktop\energia-1.8.7E21\libraries\Adafruit-MAX31865-library\Adafruit_MAX31865.cpp:224:9: error: 'class SPIClass' has no member named 'beginTransaction'; did you mean 'transaction'?

     SPI.beginTransaction(max31865_spisettings);

         ^~~~~~~~~~~~~~~~

C:\Users\Gio\Desktop\energia-1.8.7E21\libraries\Adafruit-MAX31865-library\Adafruit_MAX31865.cpp:224:26: error: 'max31865_spisettings' was not declared in this scope

     SPI.beginTransaction(max31865_spisettings);

                          ^~~~~~~~~~~~~~~~~~~~

C:\Users\Gio\Desktop\energia-1.8.7E21\libraries\Adafruit-MAX31865-library\Adafruit_MAX31865.cpp:236:9: error: 'class SPIClass' has no member named 'endTransaction'; did you mean 'transaction'?

     SPI.endTransaction();

         ^~~~~~~~~~~~~~

exit status 1
Error compiling for board RED LaunchPad w/ msp432 EMT (48MHz).

this sketch worked in arduino uno and mega..i think it might have to do with the library being use..i installed the msp RED package from tools>boards, i replaced the core folder with msp432's core i found online...still no luck...

Windows 10
Energia 1.8.7E21

  • EDIT: I wasted so many hours searching on the web and im pretty sure it has something to do with the Adafruit_Max31865/SPI and the version of arduino it was developed for.....so...is there a way to make things work?

    first thing i did was to check all available version compatibilities, like, older SPI.cpp/newer MAX31865.cpp and all possibilities concerning the two...

    i tried to use and older version of Energia 1.6.10E18 (currently on 1.8.7E21) again nothing happened...is it exclusively the adafruit_max31865 library im using ? is there any settings or tweaks i can do in the code to make it work?

    the code i used is as follows:

    //#include <SoftwareSerial.h>
    #include <SPI.h>
    #include "Wire.h"
    #define DHTPIN 50 
    #define DHTTYPE DHT22 
    #define P0 1013.25
    #include <Adafruit_MAX31865.h>
    //SoftwareSerial MSP(31,32);
    
    int CS1=32,CS2=11,CS3=12,CS4=13;
    //U8GLIB_ST7920_128X64 u8g(38, 39, 40, U8G_PIN_NONE); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
    //PT100-MAX31865 SETUP
    // Use software SPI: CS, DI, DO, CLK
    //Adafruit_MAX31865 max1 = Adafruit_MAX31865(53, 51, 50, 52);
    //Adafruit_MAX31865 max2 = Adafruit_MAX31865(49, 51, 50, 52);
    // use hardware SPI, just pass in the CS pin
    //Adafruit_MAX31865 max_1 = Adafruit_MAX31865(CS1);
    //Adafruit_MAX31865 max_2 = Adafruit_MAX31865(CS2);
    //Adafruit_MAX31865 max_3 = Adafruit_MAX31865(CS3);
    //Adafruit_MAX31865 max_4 = Adafruit_MAX31865(CS4);
    //Adafruit_MAX31865 max_1 = Adafruit_MAX31865(53, 51, 50, 52);
    //Adafruit_MAX31865 max_2 = Adafruit_MAX31865(49, 51, 50, 52);
    
    #define RREF      430.0
    // The 'nominal' 0-degrees-C resistance of the sensor
    // 100.0 for PT100, 1000.0 for PT1000
    #define RNOMINAL  100.0
    String F,g;
    float t=0,h=0,pt1=0,pt2=0,pt3=0,pt4=0;
    
    
    
    
    void setup(){
      SPI.begin();
      Serial.begin(9600);
      Wire.begin();
    //  max_1.begin(MAX31865_3WIRE);
    //  max_2.begin(MAX31865_3WIRE);
    //  max_3.begin(MAX31865_3WIRE);
    //  max_4.begin(MAX31865_3WIRE);
    
    
      
    }
    void loop(){
    
    //PT100
    //  digitalWrite(CS1, LOW); 
    //  uint16_t rtd1 = max_1.readRTD();
    //  float ratio1 = rtd1;
    //  ratio1 /= 32768;
    //  pt1=max_1.temperature(100, RREF);
    //  Serial.println(pt1);
    //  digitalWrite(CS1, HIGH); 
    //  delay(100);
    //  
    //  digitalWrite(CS2, LOW); 
    //  uint16_t rtd2 = max_2.readRTD();
    //  float ratio2 = rtd2;
    //  ratio2 /= 32768;
    //  pt2=max_2.temperature(100, RREF);
    //  Serial.println(pt2);
    //  digitalWrite(CS2, HIGH);
    //  delay(100);
    //  
    //  digitalWrite(CS3, LOW); 
    //  uint16_t rtd3 = max_3.readRTD();
    //  float ratio3 = rtd3;
    //  ratio3 /= 32768;
    //  pt3=max_3.temperature(100, RREF);
    //  Serial.println(pt3);
    //  digitalWrite(CS3, HIGH); 
    //  delay(100); 
    //  
    //  digitalWrite(CS4, LOW); 
    //  uint16_t rtd4 = max_4.readRTD();
    //  float ratio4 = rtd4;
    //  ratio4 /= 32768;
    //  pt4=max_4.temperature(100, RREF);
    //  Serial.println(pt4);
    //  digitalWrite(CS4, HIGH); 
    //  delay(100);
    
    
    
    
    delay(1000);
    }

     Can anyone even verify if this is reproducng any errors? i ll post the adafruit_max31865 library below

    Adafruit_MAX31865.rar

  • Hi Gio,

    the Energia SPI implementation of the MSP432 is still on an older version where the beginTransaction and endTransaction are not available.

    There is already a request filled to add this but no one volunteered so far.

    To get the library running with the current SPI library you can do following in the MAX31865 library.

    Comment:

    //static SPISettings max31865_spisettings = SPISettings(500000, MSBFIRST, SPI_MODE1);
    
    
    and
     //if (_sclk == -1)
    
      // SPI.endTransaction();
    
    

    Replace:

    if (_sclk == -1)
    
       SPI.beginTransaction(max31865_spisettings);
    
     else
    
       digitalWrite(_sclk, LOW);

     

    with

     if (_sclk == -1){
    
       //SPI.beginTransaction(max31865_spisettings);
    
       SPI.setBitOrder(MSBFIRST);
    
       SPI.setDataMode(SPI_MODE1);
    
    SPI.setClockDivider(SPI_CLOCK_DIV32);
    
     }else{
    
       digitalWrite(_sclk, LOW);
    
     }

    Note: i could not test the function as i do not have a MAX board but i compiles without errors.

    Regards,

    Stefan

  • Thanks for the repsonse stefan,

    the SPI finally works following the steps you mentioned above!!

    i tested it with my MAX31865 and pt100 RTD for measuring temperature and i get the temperature data!

    thanx again man!!

**Attention** This is a public forum