Esp32_position_control example does not compile for ESP32 Wrover Module

I was using the Arduino-FOC with the STM32 which worked nicely.
Now I set it up with an ESP32 Wrover (board version 1.0.4), trying both the current master-branch and dev-branch (31.08.20) and it does not compile. the …\examples\hardware_specific_examples\ESP32\magnetic_sensor\esp32_position_control .

Arduino throws the following error message:

`C:\Users\Josefin\Documents\Arduino\libraries\Arduino-FOC-dev\src\FOCutils.cpp: In function ‘void _setPwmFrequency(int, int, int)’:

C:\Users\Josefin\Documents\Arduino\libraries\Arduino-FOC-dev\src\FOCutils.cpp:108:55: error: ‘MCPWM_SELECT_SYNC_INT0’ was not declared in this scope

mcpwm_sync_enable(m_slot.mcpwm_unit, MCPWM_TIMER_0, MCPWM_SELECT_SYNC_INT0, 0);`

How can I fix this?
Thanks for your help!

P.S. I also posted the same on github:

Hello @kmjh,

Easy fix! You just need to replace a file in your arduino installation and it will compile.

Here you can find the steps in the ESP32 section.

Ah that was easy! Thanks a lot!

1 Like

I’m having the same issue using VScode and platformio, but I cannot fix in the same way.

Are you sure you replaced the correct file?

@Owen_Williams, is this file located somewhere else for platformio/vscode?

that is the only place where I got that file on my machine.

Worked for me by putting corrected mcpwm.c and mcpwm.h into:
~/projectdir/.pio/libdeps/%board%/Simple FOC/src/drivers/hardware_specific/driver

and mcpwm_periph.h into:
~/projectdir/.pio/libdeps/%board%/Simple FOC/src/drivers/hardware_specific/driver/soc

Could be useful to make it part of the library - so it complies automatically with new version without manual fiddling with headers.

found a solution,
platofrmio is downloading a new set of library (is not using the one installed from Arduino) this is the path I’ve found on mine.

my global search didn’t found it ( may be because is an hidden folder), just wondering that maybe an update will overwrite that again.

thanks all.

Thanks for sharing the solution :slight_smile:

Hi - it looks like the link @David_Gonzalez shared has been changed and no longer has instructions to fix this issue (or maybe I am blind haha). Can anyone share some more info on the file that needs to be changed?

Hey @scferro,

We have removed this as requirement from docs becauser from the version 2.1.1 this should no longer happen. The source code has been updated not to use the ESP32 code that requires the changement.

Are you still having some issues with that?

Thanks for the quick response! A library update seems to have fixed the issue

Awesome, I’ll make sure to put it in the docs for the earlier versions!