Compilation Error for Machine Control M4 Core

I'm trying to run the Digital Outputs using the M4 Core but I'm having the following error in my compilation:

Arduino: 1.8.19 (Windows 10), Board: "Arduino Portenta H7 (M4 core), 1MB M7 + 1MB M4"

C:\Users\bwilliams\Documents\Arduino\libraries\ArduinoRS485\src\RS485.cpp:189:18: error: 'SERIAL_PORT_HARDWARE' was not declared in this scope
 RS485Class RS485(SERIAL_PORT_HARDWARE, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
                  ^~~~~~~~~~~~~~~~~~~~
C:\Users\bwilliams\Documents\Arduino\libraries\ArduinoRS485\src\RS485.cpp:189:18: note: suggested alternative: 'SERIAL_PARITY_SPACE'
 RS485Class RS485(SERIAL_PORT_HARDWARE, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
                  ^~~~~~~~~~~~~~~~~~~~
                  SERIAL_PARITY_SPACE
exit status 1
Error compiling for board Arduino Portenta H7 (M4 core).

Code I'm trying to run:

#include "Arduino_MachineControl.h"
#include <Wire.h>

using namespace machinecontrol;

void setup() {
  Wire.begin();
  digital_outputs.setLatch();
  digital_outputs.setAll(0);
  if(!digital_inputs.init()){
    //digital_input initialization failed
    errorFlash(); 
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  if(digital_inputs.read(0)){ //if Button press (DIN pin 0) is high then turn on lights
    digital_outputs.set(0,HIGH);
    delay(100);
    digital_outputs.set(0,LOW);
  }
}

void errorFlash(){
  while(1){
      digital_outputs.set(7,HIGH);
      delay(500);
      digital_outputs.set(7,LOW);
      delay(500);
  }
}

I suspect that the error is caused because the M7 core handles the Serial communication leaving the M4 core unable to be used with the Machine Control library. Any ideas on a workaround?

In order to make all relevant information available to any who are interested in this subject, I'll share a link to the related discussion here:

1 Like

I have the same issue. Would be great if the fix mentioned here gets merged into the Arduino_MachineControl library.

1 Like

I think, there is a macro CORE_CM7 vs. CORE_CM4. If you enclose your code in
#ifdef CORE_CM7
...
#endif
it should avoid to compile the same code again for the other core.

But, I guess: CM7 and CM4 can access UART, but with just a different name, e.g. Serial vs. Serial1.

The main tool for me to handle such compile errors - because the IDE lacks so much on browsing declarations, definitions, opening H-file ...:

  • have a copy of the GIT repository (or at least know where the Arduino and mbed H-Files are on PC filesystem, e.g. C:\Users<user>\AppData\Local\Arduino15... )
  • and a WinGrep tool (grepWin) used there (Windows should have also a "find" command line tool... to find text in files)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.