error loading emg dfrobot sensor code into an arduino portenta h7

userHead Daniel.martinez 2023-06-28 02:56:00 240 Views4 Replies

When compiling the code I get the following error "Compile error: invalid conversion from 'int' to 'SAMPLE_FREQUENCY' [-fpermissive]", but it only happens when I use the arduino portenta h7, when I use a leonardo it works fine.

any solution?

2023-07-19 14:20:46

So here is how I locate this problem, 

1. When compailed the sample code under the Arduino Portenta H7. The prompt in the output monitor shows that the parameter in the init() function is using “SAMPLE_FREQUENCY” and “NOTCH_FREQUENCY” as it's data type.

Apparently not a C++ built-in data type

 

2.So I went to the .h file of the EMG library, noticed that those two data type was user defined by the "enum"

Normally, during the compilation process, the C++ compiler will automatically match the data type generated by the enum to the incoming argument. (Because enum is actually batched #define)

In the Arduino UNO/Leonardo, the compiler did that in the right way. But in the Arduino H7, don't know somehow it didn't work in this way.

 

3. To verify my guess, I kept the code in the mininum size and compile my own code under Arduino UNO and Arduino H7.

You could see the difference.

In UNO, my code works well

 

 

But in Protenta H7, my code crashed

 

 

 

The above is my initial solution to your problem, unfortunately I don't have Protenta H7 in hand to do more tests.In my spare time, I will check the source code of Protenta H7's underlying SDK and understand the C++ version used by Protenta H7.If I find a problem, I will submit this issue to Arduino's GitHub as soon as possible

 

userHeadPic Yeez_B
2023-07-19 14:05:53

Hello Daniel,

   After a few test, I guess this may be a problem with the underlying SDK of Arduino Portenta H7. Moreover, it is a problem with the C++ compiler inside the SDK. It cannot automatically convert the "int" type to the user-generated data type in "enum". (sorry I'm not a native English speaker, I'm not sure if my terminology is correct when it comes to programming)

 In order to let you solve this problem quickly, I put the solutuion here first:

Please change the data type of above two variable from “int” into what I changed in the above picture.

 

And I compailed the code perfectly:

 

userHeadPic Yeez_B
2023-07-18 17:53:11

Hi!

Please delete this "A" character.

userHeadPic jenna
2023-06-28 03:09:39
userHeadPic Daniel.martinez