RP2040 vs STM32G431 for long term, broadly applicable motor driver board

I know the general consensus appears to be that the fast m4 core and so on is really the way to go. The STM32 has features for the timers and so on that are useful. It’s got built in op amps and comparators. Faster, better ADC (RP2040 only has 3 adc pins).


RP2040 has some important advantages:

  1. Backed by the rpi foundation. Might have a successor that is even better. The arduino stuff is relatively well supported, while the STM32 arduino support seems to be a bit of an afterthought.
  2. Two cores. I’m not too clear how well the second core can actually be used under arduino. Like will you get random crashes or is it ready for prime time? It’s always a struggle to get that last bit of refinement to make something truly useful…But I think the two cores would simplify and improve things in many ways and helps a lot to make up for the lack of floating point. One core makes the waveforms, the other one watches, handles communication, all the slow stuff. Even checking I2C angle sensors takes a long time under arduino. Even printing debugging stuff is an issue in arduino (it seems to be very slow for some reason). Having the second core do that stuff could be a pretty useful approach in general.
  3. no supply issues. Remember the STM32 chips had real supply issues only recently.
  4. The rp2040 does have significant advantages like the PIO stuff. You can use almost any pins for almost any input/output port type. No need to worry too much about which pins you got broken out and which you don’t.

No need for an st-link, I could make a “hat” for the pico board, i.e. a board with a few header pins that fits under the pico. I think that would do what I need pretty well.

But, again, I don’t want to do the thing where I just make something that hardly works even for my own purposes and is overpriced and of almost no value to anyone else. I would be leveraging the prior design work of any hats for the pico, and stealing components that are known to be relatively good choices (in jlcbpcb library, good value etc.). Trying to use the relatively well refined stuff where I can, when I can, rather than trying to repeat all the labor all over again and then doing a poor job because I don’t have time to do it properly anyway.

Sequoia is working on a driver board based on the rp2040 but it’s a dual driver I think. I want the unit sized one. If you need, two, you just put two boards together…

A lot of this comes down, imo, to where labor effort is best directed. If the chips become unavailable, then the work done on the board and code base which is compatible becomes useless pretty fast. Also, it seems like every new feature takes a lot of work to get rolling under STM32, all the crazy modifications to the arduino ide, which the arduino ide isn’t really built for (compiler flags etc), to get the stuff working that people are always having a hard time with.

I mean has anyone actually used any of these fancy timer features and stuff that are available on the STM32 but not rp2040? How often does that happen and how much value does it really give in the end? Seems like it’s usually too much hassle anyway.

Having worked quite a bit with both, STM32G4 wins easily for motor control applications in my opinion. It may have only one core, but that core is considerably faster, and SimpleFOC is further accelerated thanks to FPU and CORDIC acceleration.
The Arduino framework for STM32 is excellent, and well supported by ST Micro. The RP2040 Arduino support is not good, and the official board package is based on mbed and has awful performance.
In terms of pricing the price of the cheapest G4s like the G431CBU has come down so low that it is quite competitive with the RP2040, where you also have to factor in more external components for flash.
Finally, the lack of motor control features in the ADC disqualifies the RP2040 completely.

While I think RP2040 is a very nice MCU, for motor control applications I would always prefer the STM32G4.


Add also lack of comparators. G431 has two internal iirc.



The RP2040 Arduino support is not good,

Are you sure? From time to time I take a look on the progresses of the EarlyHillpower Arduino Framework and I have the impression it is constantly evolving:
Pipico Arduino Framework

I never tried it but will soon and for me it seems quite easy to use two cores:
PiPico Dual Core Example

1 Like

Philearlehower’s core has much better performance with SimpleFOC but unfortunately it’s not the official one…

The difficulty comes in when trying (for example) to share data >32bits (requiring mutexes) or using peripherals (which core is handling the interrupt again?)

Regarding the communication between the two cores I think it is not that difficult. You can lock whole blocks by flags (mutex) and assure the synchronisation. Try to reduce the communication links between the two cores.

Two cores have the major advantage that you can run the time critical task full speed on one core with no interrupts and using polling instead.

1 Like

I would also say: you don’t need an STLINK if somehow that $11 is a barrier for you- it (G431) supports USB-DFU for updating firmware over USB without any special tools. The G431 has become my go-to for every project I do, even as someone who previously used rp2040/pico for quite a lot. The libraries and tools from ST and community are just absolutely fantastic, better than anything from RP or Espressif, imo

1 Like

NUCLEO-G431KB dev board is $12 and comes with the stlink bundled into the package. Only thing a developer needs is a USB cable. It has 26 useable i/o pins vs Pico’s 24 i/o pins. 12 analog pins vs Pico’s 3 analog pins (which are having a hardware nonlinearity bug preventing them from properly functioning anyways). 213 Dhrystone MIPS vs about 100 Dhrystone MIPS for RPi Pico (80 to 150 D-MIPS depending on optimization options).


More about the rpi2040 adc silicon problem


1 Like

Sigh, seems like the g431 is the way to go until the next gen rp2040. Oh well. Better to know, whatever the truth is!

1 Like

Sure, but this limits you to using the nucleo32 - you could also get the much larger and featured G474RE nucleo (64) for about the same price, and you can get the chip itself for like $2 on LCSC- it’s super flexible IMO.

1 Like