# Issues with the library on different boards

**URL:** https://community.simplefoc.com/t/issues-with-the-library-on-different-boards/6428
**Category:** Uncategorized
**Tags:** nucleo
**Created:** [December 5, 2024, 11:08am UTC](https://community.simplefoc.com/t/issues-with-the-library-on-different-boards/6428 "2024-12-05T11:08:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![nakeze](https://community.simplefoc.com/user_avatar/community.simplefoc.com/nakeze/32/7914_2.png) [@nakeze](https://community.simplefoc.com/u/nakeze)
#### Post date: [December 5, 2024, 11:08am UTC](https://community.simplefoc.com/t/issues-with-the-library-on-different-boards/6428/1 "2024-12-05T11:08:28Z")

</div>

Hi,  
I have a project that needs to drive a motor quite fast and that use a AS5048a magnetic sensor as encoder.

I first developped it on the Arduino UNO without issues except its computation capacity (16mHz, loop called every 1 ms). I purchased different boards (nano connect, nano esp32, nucleo L432KC, teensy 4.0, pi pico) in order to overcome this limit.

I had a generic sketch that drove the motor in velocity openloop.  
The loop() (motor.loopFOC + motor.move(targetSpeed) took 40 ms on a rp2040 board (pi pico and nano connect, arduino-pico 3.1.1 and simple FOC 2.3.4).  
Upgrading the arduino-pico board to 4.3.1, The same loop took 50 us.  
However, the MagneticSensorSPI base class .init() blocks the program. I used an homemade sensor class to overcome that and test.

I tried the NUCLEO-L432KC board, but as soon as the simplefoc library is included, the program compiles but is not executed (tried with blink…).  
The nucleo board is STM32 MCU based boards 2.9.0.

I also tried an esp32 nano board but I couldn’t program without force reseting the board. This issue was not related to the simple foc library

---

<div class="post-metadata">

### Author: ![quentin](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/q/e47c2d/32.png) [@quentin](https://community.simplefoc.com/u/quentin)
#### Post date: [December 5, 2024, 11:19pm UTC](https://community.simplefoc.com/t/issues-with-the-library-on-different-boards/6428/2 "2024-12-05T23:19:26Z")

</div>

Hi @nakeze,  
It’s definitely possible to overcome your 1 ms limit. I use an ESP32 to drive two motors in closed-loop mode (and two AS5048a, using [this driver](https://github.com/simplefoc/Arduino-FOC-drivers)) and I achieve 0.15 ms.

---

<div class="post-metadata">

### Author: ![nakeze](https://community.simplefoc.com/user_avatar/community.simplefoc.com/nakeze/32/7914_2.png) [@nakeze](https://community.simplefoc.com/u/nakeze)
#### Post date: [December 6, 2024, 9:03am UTC](https://community.simplefoc.com/t/issues-with-the-library-on-different-boards/6428/3 "2024-12-06T09:03:46Z")

</div>

Hi Quentin,  
Yes it is definitely possible, with teensy and rp2040, the loop is over 10 khz. I wanted to list the issues that I faced, which were :

- Poor computation time with an old arduino-pico version.
- Code than don’t run on nucleo-L432KC stm32 2.9.0 even though compilation is fine.

I know that it must be hard to maintain and document all these different combinations. Maybe the page : [Microcontrollers | Arduino-FOC](https://docs.simplefoc.com/microcontrollers) could get a boad version and simple foc version compatibility that were tested at new release.

---

<div class="post-metadata">

### Author: ![Candas1](https://community.simplefoc.com/user_avatar/community.simplefoc.com/candas1/32/5296_2.png) [@Candas1](https://community.simplefoc.com/u/Candas1)
#### Post date: [December 7, 2024, 3:30pm UTC](https://community.simplefoc.com/t/issues-with-the-library-on-different-boards/6428/4 "2024-12-07T15:30:34Z")

</div>

If the code is not hanging but initialization fails somewhere, you can enable the debug [build flag](https://docs.simplefoc.com/cheetsheet/build_flags) for stm:

> SIMPLEFOC\_STM32\_DEBUG

You can enable it by adding this to the build\_blags in platformio.ini if you use platformio:

> -D SIMPLEFOC\_STM32\_DEBUG

You also need to add this to your code:

```auto
void setup(){
  Serial.begin(115200);
  SimpleFOCDebug::enable(&Serial);
  delay(3000); // wait 3s to connect serial console on PC
  ...
}

```

You will then get more details on the serial output.
