MCU Selection for Machine Control: Cortex-M, RISC-V and Motor MCUs

MCU Selection for Machine Control: Cortex-M, RISC-V and Motor MCUs

Key Takeaway

MCU selection for machine control is decided by the peripherals around the core, not by the clock speed on the front of the datasheet. Write the timing budget first, then pick the part whose timer count, ADC trigger, DMA channels and memory actually fit it.

MCU Selection for Machine Control STM32 Cortex-M MCUs RISC-V Machine Firmware C2000 Motor Control Timing Budget First, Then Part Selection justlast.in ยท Industrial Automation

1. Start From the Loop, Not From the Datasheet

This guide is written for the engineer who has to make mcu selection for machine control a decision on a real machine controller, in an Indian shop, with a board that has to be supported for ten years. Every number in it is either a datasheet figure, a standard limit, or an arithmetic result that can be checked. The sections work through mcu selection for machine control from the requirement to the part number, and the last section is a checklist you can take to a review meeting.

The most common mistake in MCU selection for machine control is to start with a part someone recommended and then look for features to justify it. Start at the other end. Write down the loop you have to run, at what rate, with what latency, and what has to happen in hardware rather than in software.

Take a typical retrofit: three axes with servo drives over CANopen, a spindle drive with a 16-bit current loop at 20 kHz, a 7.5 kW spindle motor, a 1024 ppr incremental encoder on each axis, a 4 to 20 mA pressure input, and an HMI on Modbus RTU. Write the timing budget:

Function Rate Latency budget Where it runs
Spindle current loop 20 kHz 2 us sample to PWM update Timer interrupt, ADC triggered
Axis current loop 20 kHz 2 us Same interrupt
Speed loop 500 Hz 200 us Fast task
Position loop 100 Hz 1 ms Fast task
CANopen PDO 1 ms cycle 1.5 ms DMA and hardware filter
HMI and log 100 ms 200 ms Background task

Two consequences fall straight out of that table. The 20 kHz loops must be driven by a hardware timer, because a 2 us sample-to-PWM latency cannot be guaranteed from software polling at any clock speed. And the CANopen traffic must not share the same interrupt, because the loop budget has no room for a bus frame.

Now the second constraint, which is usually the one that decides the part: the number of timers and channels. Three axes plus a spindle needs four sets of three complementary PWM outputs with independent dead time, four encoder interfaces, and at least one timer for the millisecond time base. That is 12 complementary outputs, 16 encoder inputs, and 2 ADC trigger sources. No general-purpose MCU has those numbers in the smallest pin count, so the selection question becomes which family gives them with the fewest compromises.

Section summary. The practical consequence for mcu selection for machine control is that the constraint written down first is the one that binds. In mcu selection for machine control, the peripheral set, the update scheme and the local supply decide the part, and the clock speed is almost never the deciding factor. Keep the mcu selection for machine control decision written down, because the person who maintains it will not be you.

2. The Cortex-M Families and What Each One Is For

Arm Cortex-M is the default for machine controllers in India, not because of the core but because of the ecosystem: ST’s HAL and LL drivers, the STM32CubeMX configuration tool, FreeRTOS ports, motor control workbench libraries and a distributor network that can actually deliver a replacement part in two days.

The useful subdivision inside STM32 is by application, not by generation.

STM32F4 and F7, the general-purpose workhorses. The F4 runs at 168 MHz with a single-precision FPU, has 1 MB of flash and 192 KB of RAM in the F407, and carries 3 ADCs that sample at 2.4 MSPS. It has 2 advanced timers with complementary outputs and hardware dead time, plus the usual TIM1 to TIM17 set with 4 encoder modes. It will run three cascaded position loops and a 1 kHz motion loop comfortably. The F407 is still the value choice for a multi-axis retrofit that delegates the inner motor loop to a smart drive, because all the current loop work happens inside the drive and the MCU only handles setpoints.

STM32H7, the performance end. The H743 and H753 run at 480 MHz with a 2 MB flash, 1 MB of RAM and an instruction and data cache, and the ADCs reach 3.6 MSPS. The cache is the point and also the trap: it gives very fast code execution, but a cached DMA buffer that the CPU writes and the DMA reads needs explicit cache maintenance, and getting that wrong produces a fault that appears only under load. The H7 is worth it for a machine with Ethernet, a vision-ish feature or very heavy logging. It is not worth it for a three-axis controller.

STM32G4, the motor control parts. The G431 and G474 are the ones to look at for an in-house current loop. Both run at 170 MHz with an FPU. The G474 has 512 kB of flash, 128 kB of RAM, 5 ADCs sampling at up to 4 MSPS, 6 HRTIM instances with 4 outputs each and a dead time generator with roughly 0.2 ns resolution, 4 timers with 4x encoder mode, 6 operational amplifiers, 7 comparators, a hardware CORDIC and a filter math accelerator. That is a complete motor control subsystem on one die, and it is why the G4 has become the default for a custom drive in this class.

Do the timer arithmetic for the G4 at 170 MHz. For a 20 kHz PWM with an up-down counter the period register is 170e6 / (2 x 20000) = 4250, so a 16-bit timer has ample resolution and the dead time setting at 0.2 ns steps can express anything from 100 ns to 10 us. For a centre-aligned mode with complementary outputs and the ADC triggered at the counter underflow, the sample lands at the centre of the on-time where the ripple from the freewheeling diode is smallest.

NXP MCX and Renesas RA. The NXP MCX N and A series are Cortex-M33 or Cortex-M33 with TrustZone at 150 to 200 MHz, and the RA4 and RA6 from Renesas are Cortex-M4 at 48 MHz up to Cortex-M33 at 200 MHz. Both are perfectly good machine parts with good low-power modes and comparable toolchain maturity. Where they are weaker in India is the availability of application notes, motor control workbench code and local technical support. That is a legitimate tie-breaker, not a technical one.

Section summary. To close this section: mcu selection for machine control is an exercise in matching a requirement to a part, and the requirement is the hard part. In practice mcu selection for machine control succeeds when the timing budget, the memory budget and the availability of the part are all answered in writing before a single part number is chosen. A structured mcu selection for machine control process is cheaper than a respin.

3. RISC-V: Where It Fits and Where It Does Not

RISC-V is no longer a curiosity, and for a machine controller it is worth a serious look. The instruction set is open, the core is available from several sources, and the cost pressure in a volume product is real.

GD32F303 and the GD32 family from GigaDevice are the most immediately interesting in India because they are pin and peripheral compatible with a large slice of the STM32F1 and F4 line, are stocked locally, and cost a fraction of the price. A GD32F303 at 120 MHz with 128 kB of flash and 20 kB of RAM is around one third the cost of the equivalent STM32F4 in distributor pricing. That is a real advantage for an OEM building thousands of controllers.

The catch is the ecosystem. The register compatibility is at the level of the reference manual, not the level of the HAL, so the driver work is not free, and the ARM Cortex ecosystem of middleware, reference designs and community support does not transfer.

NXP’s RISC-V MCX N1 and N2 are the serious industrial option. These are the same family as the Arm MCX parts but with a RISC-V core, and NXP positions them for industrial control with the same tools, the same MCUXpresso IDE and the same peripherals. For a company already using NXP MCX, the RISC-V switch is close to painless, which is exactly why it is worth watching.

Where RISC-V does not fit yet: anything where you need a safety certification argument, because the qualification evidence base is thin; anything where a vendor application note would have saved you a month; and anything where the controller must run a fieldbus stack that is only supported on Arm.

And explicitly, the ESP32. The ESP32 is a superb low-cost Wi-Fi and Bluetooth part and it is the right answer for a gateway, an IoT logger or an HMI terminal. It is the wrong answer for a real-time machine controller. Its two Xtensa LX6 cores at 240 MHz have no hardware FPU, the FreeRTOS port has a software FPU option that costs a large fraction of the cycle budget, the internal ADC is noisy with no reference accuracy, and there is no deterministic multi-timer arrangement for a current loop. It can be made to do the job, and people have, and the result is a controller that works on the bench and misbehaves when the cabinet is hot.

Section summary. Everything in this section comes back to one discipline: mcu selection for machine control is decided by the timing budget, not by the feature list. When you work through mcu selection for machine control, write the loop periods and the memory budget down first and only then compare the parts. A mcu selection for machine control decision that starts from a datasheet headline usually ends with the board being replaced.

4. Dedicated Motor Control MCUs

If the controller runs the inner motor loop itself, a dedicated motor control MCU is worth the money. The premium buys you the things that are hard to add later: a high resolution PWM, a fast and settled ADC, a good opamp set, and a vendor motor control library that has already been debugged.

Texas Instruments C2000 is the reference platform for real-time motor control. The TMS320F2837xD runs at 200 MHz with two 12-bit ADCs sampling at 3.1 MSPS and a high resolution PWM module with 310 ps resolution on the edge positions, which is what allows a very short dead time on a large IGBT or a GaN FET. The digital control library is mature and the digital power control library takes you from a datasheet to a working inverter. The parts cost in the range of Rs 1200 to Rs 4000 depending on the package, which is 5 to 10 times a general-purpose STM32.

Infineon XMC is the other serious family. The XMC4000 has a Cortex-M4F at 100 MHz, a 12-bit ADC and the CCU8 and CCU5 timer units with multiple independent channels, which is a natural fit for a three-phase inverter with more than one bridge on the board. The XMC1400 parts have a well-integrated motor control subsystem and are widely used in the Indian small-motor drive industry.

STM32G4 is the middle path, and in a machine retrofit it is usually the right one. A G474 costs a fraction of a C2000, the toolchain and libraries are free, and the on-chip opamps and comparators remove the need for a separate current-sense amplifier board. Where you will need to spend the money on a G4 is on a good external current sense amplifier and on the power stage itself.

There is also the option of not doing it at all. Buying a smart servo drive that closes its own current loop and accepts a position or velocity command over CANopen moves the hardest real-time work into a product that somebody else has certified and tested. For a machine with two or three axes, that is often the cheapest and the most reliable decision. The field oriented control guide covers what you give up and what you keep when you make that choice.

Section summary. The practical consequence for mcu selection for machine control is that the constraint written down first is the one that binds. In mcu selection for machine control, the peripheral set, the update scheme and the local supply decide the part, and the clock speed is almost never the deciding factor. Keep the mcu selection for machine control decision written down, because the person who maintains it will not be you.

5. The Peripherals That Actually Decide the Choice

Now the checklist. These are the questions to ask the datasheet, and each one has a number attached.

Timers and complementary outputs

Count the timers you need with their channel counts and their special functions. For a four-axis machine you need four advanced timers with three channels each (U, V, W with complementary pairs), four timers in encoder mode, one timer for the 1 ms time base, and a spare. A general-purpose Cortex-M with two advanced timers cannot do it, and no amount of software fixes that. The dead time generator matters more than the PWM frequency: at 20 kHz the period is 50 us, so a 2 us dead time is 4 percent of the period, and a hard-coded dead time that is too long costs you torque at low speed and causes distortion that shows up as a temperature rise in the motor.

ADC: triggered sampling, not polled sampling

The critical specification is not the sample rate, it is the trigger. The ADC must be able to start a conversion on a timer event, with the conversion complete flag routed to a DMA request, so the whole sample-to-compute-to-PWM chain is hardware-sequenced. A 12-bit ADC at 4 MSPS takes 250 ns to convert, so the trigger-to-data latency is short, but the jitter between the timer event and the actual sample is what destroys a current loop. Ask for the trigger latency spec, not the throughput spec.

DMA channels and the bus matrix

Every fast data path should be DMA: the encoder counters, the ADC results, the CANopen mailbox, the Modbus buffer, and the SPI or UART for the HMI. A Cortex-M4 has 2 DMA controllers with 7 channels each, so 14 streams. A design that uses 6 is comfortable; a design that needs 14 has no margin for the next feature.

Encoder interface

The timer encoder mode counts the A and B channels and uses Z as the index. What decides it is the maximum input frequency. A 1024 ppr encoder at 3000 rpm gives 1024 x 3000 / 60 = 51200 edges per second, and the timer counts at 4x so the counter must handle 512000 counts per second. That is easy. A 23-bit serial encoder at 1 MHz pushes the job to the serial engine instead, which is a completely different design, and that is why the encoder choice and the MCU choice are made together. The interface detail is in the encoder interfaces guide.

Analogue inputs: the resolution trap

A 12-bit ADC on a 3.3 V reference gives 3.3 / 4096 = 0.806 mV per count. For a 0 to 10 V signal scaled through an 8:1 divider to 0 to 1.25 V, one count is 0.806 mV at the ADC, which is 6.45 mV at the input, or 0.0645 percent of the 10 V span. If the process needs better than 0.1 percent, a 12-bit ADC cannot deliver it no matter how good the reference is, and you need a 16-bit part or a sigma-delta modulator. Measure the requirement before you pick the converter.

Section summary. To close this section: mcu selection for machine control is an exercise in matching a requirement to a part, and the requirement is the hard part. In practice mcu selection for machine control succeeds when the timing budget, the memory budget and the availability of the part are all answered in writing before a single part number is chosen. A structured mcu selection for machine control process is cheaper than a respin.

6. Sizing Flash and RAM Properly

Memory is the easiest place to get a design wrong, because the application size is not what determines the part size. The bootloader scheme is.

Do the flash budget for a machine that needs safe field updates. A bootloader with a UART recovery console and a CRC32 check needs 16 to 24 kB. The application with HAL, FreeRTOS, CANopen and Modbus typically lands at 90 to 140 kB. With A and B slots for atomic updates, the requirement is 2 x 140 + 24 = 304 kB, which rounds up to a 512 kB part. On a 256 kB part you have to give up either the A and B scheme or the CANopen stack, and giving up the A and B scheme means a power cut during an update bricks the controller.

On RAM, the arithmetic is similar. The STM32G431 has 32 kB of RAM, and FreeRTOS with 10 tasks at 1 to 2 kB of stack each, plus the heap, plus the ADC and CAN buffers, uses 18 to 25 kB of that. It works, with no margin. The G474 with 128 kB of RAM is comfortable, and the H7 with 1 MB is comfortable to the point of waste.

The general rule for Indian machine builders: buy the next size up in RAM, because adding a field update feature or a second fieldbus two years after commissioning will need the memory and you cannot add RAM to a soldered part.

Section summary. Everything in this section comes back to one discipline: mcu selection for machine control is decided by the timing budget, not by the feature list. When you work through mcu selection for machine control, write the loop periods and the memory budget down first and only then compare the parts. A mcu selection for machine control decision that starts from a datasheet headline usually ends with the board being replaced.

7. Temperature Grade, Availability and Cost in India

Two commercial specifications decide more machine projects than the clock frequency.

Temperature grade. A cabinet in a shop in Pune in May sees 45 deg C ambient easily, and a closed cabinet with a drive running inside it sees more. An industrial grade part rated -40 to 85 deg C costs a small premium over a commercial grade -20 to 85 deg C part. The failure mode of getting it wrong is not dramatic; the controller simply works in the morning and misbehaves in the afternoon as the board heats up, and that pattern sends the engineer looking for firmware bugs for a week.

Availability. India is a strong market for STM32, and most large cities have distributors with stock. It is much weaker for TI C2000, Infineon XMC and Renesas RA, where a single missing part can hold a production batch for six weeks. For an OEM building a machine that will be sold in volume, the sensible policy is to design around a family with at least two stocked sources and to keep the pin count low enough that an alternative part can be dropped in.

Indicative distributor pricing for 1000-piece quantities in 2026, for the MCU only, before the board:

Family Part Flash / RAM Approx. unit price Stock in India
GD32 GD32F303 128 kB / 20 kB Rs 55 to 100 Good
STM32F1 STM32F103 128 kB / 20 kB Rs 90 to 160 Very good
STM32F4 STM32F407 1 MB / 192 kB Rs 180 to 320 Very good
STM32G4 STM32G474 512 kB / 128 kB Rs 280 to 520 Good
NXP MCX N14x up to 1 MB / 256 kB Rs 250 to 500 Fair
Renesas RA6M5 2 MB / 1 MB Rs 400 to 750 Fair
TI F2837xD 512 kB / 204 kB Rs 1200 to 4000 Poor
Infineon XMC4000 256 kB / 128 kB Rs 700 to 1500 Fair

These are ranges, not quotes, and they move with the rupee and the distributor. The point of the table is the shape of the decision: the general-purpose parts cluster around Rs 100 to 500 and are easy to get, and the specialised motor control parts cost five times as much and are harder to source. That is the real price of building the current loop in-house.

Section summary. The practical consequence for mcu selection for machine control is that the constraint written down first is the one that binds. In mcu selection for machine control, the peripheral set, the update scheme and the local supply decide the part, and the clock speed is almost never the deciding factor. Keep the mcu selection for machine control decision written down, because the person who maintains it will not be you.

8. A Worked Selection for a Three Axis CNC Retrofit

Let the requirement be a 3-axis retrofit of a manual mill, with a 1.5 kW servo on each axis, an encoder on each, a spindle VFD over Modbus, and a pendant HMI over Modbus RTU.

Decision one: who closes the spindle current loop? The spindle is an induction motor on a standard VFD, so the drive closes its own current loop and the controller only sends speed references. No custom current loop is needed for the spindle.

Decision two: who closes the axis current loop? The axis servos are smart servo drives over CANopen that close their own current and speed loops, so the controller only runs a position loop at 100 Hz. No custom current loop for the axes either.

Consequence: the tightest timing requirement left is the 100 Hz position loop with a 1 ms deadline, plus a CANopen cycle of 1 ms, plus Modbus RTU polling of the VFD at 100 ms. That is a general-purpose application, not a motor control application.

Selection: an STM32F407VGT6. 168 MHz, 1 MB of flash which comfortably holds the bootloader plus one application slot plus a spare, 192 kB of RAM which is more than a bare-metal or small FreeRTOS design needs, 3 ADCs, 4 timers in encoder mode if local counting is wanted, and CAN and UART peripherals on board. Two advanced timers are enough because the axis current loops are inside the drives.

What was rejected and why: the G474 was rejected as unnecessary, because without a custom current loop the HRTIM and the fast ADC buy nothing. The H7 was rejected as overkill at 4 to 5 times the cost. The GD32F303 was rejected because its 20 kB of RAM is too tight for an RTOS design with a CANopen stack, and a design that has to choose between RAM and features is a design that will be replaced in year two.

Cost impact of that decision: the MCU choice moved the BOM by roughly Rs 150 against the G474, but the G474 board would also have needed an external current sense amplifier, a more careful layout for the fast ADC and a different PCB. The board cost would have been higher, not lower.

Section summary. To close this section: mcu selection for machine control is an exercise in matching a requirement to a part, and the requirement is the hard part. In practice mcu selection for machine control succeeds when the timing budget, the memory budget and the availability of the part are all answered in writing before a single part number is chosen. A structured mcu selection for machine control process is cheaper than a respin.

9. Migration Risk and How to De-Risk It

The expensive mistake in MCU selection is choosing a part that cannot grow. Three specific risks are worth designing around.

Peripheral migration. Moving from an F4 to an H7 is not a recompile. The clock tree changes, the GPIO and peripheral base addresses move, the HAL has new modules, and the DMA and cache interaction has to be handled. Plan for it as a board-level redesign with a second spin of the PCB, not as a firmware task.

Pin compatibility. Within STM32, the same package and pinout often exists across families, for example the LQFP48 and LQFP100 footprints are reused across F1, F4, G4 and H7 in several places. Designing to an LQFP100 footprint instead of an LQFP48 gives you a pin-compatible upgrade path for the price of a bigger board. This is cheap insurance and it is worth taking when the machine will be sold in volume.

Flash endurance. The parameter storage is where flash wear bites. A machine that stores recipe parameters to internal flash on every change will exhaust the endurance in a few years. An FRAM or an external I2C EEPROM costs under Rs 40 and removes the problem, and the wear levelling code disappears with it.

Supply. Two things to do at design time: keep the pin count as low as you can so a second-source part can be fitted, and buy a first article of the alternates and test them on the board, not on the datasheet. A part that fits and passes the smoke test in week one costs nothing; the same discovery in week thirty costs a month.

Section summary. Everything in this section comes back to one discipline: mcu selection for machine control is decided by the timing budget, not by the feature list. When you work through mcu selection for machine control, write the loop periods and the memory budget down first and only then compare the parts. A mcu selection for machine control decision that starts from a datasheet headline usually ends with the board being replaced.

10. A Decision Checklist to Close the Task

Before the part number goes on the BOM, answer these in writing.

  • What is the tightest deadline, and is it met by hardware or by software?
  • Do the timers provide the complementary outputs, the encoder modes and the dead time the design needs, with at least one spare?
  • Is the ADC trigger chain hardware-sequenced from the PWM timer?
  • How many DMA streams does the design use, and is there headroom for one more feature?
  • Does the flash budget include the bootloader and the update slots?
  • Is the RAM budget including the RTOS stacks, measured with high water mark, not estimated?
  • Is the part rated to 85 deg C, and stocked by a distributor you have a relationship with?
  • Is there a pin-compatible upgrade path, and has the alternate been tested on real hardware?

If every answer is specific, the choice is made and it will hold. If any answer is a shrug, the design is not ready and the datasheet is being read instead of the requirements. The broader architecture context is in the embedded systems for industrial machines guide, and the scheduling decision that follows the MCU choice is in the RTOS versus bare metal guide.

Section summary. The practical consequence for mcu selection for machine control is that the constraint written down first is the one that binds. In mcu selection for machine control, the peripheral set, the update scheme and the local supply decide the part, and the clock speed is almost never the deciding factor. Keep the mcu selection for machine control decision written down, because the person who maintains it will not be you.

Sources

  1. STM32G4 mixed-signal microcontrollers with HRTIM
  2. Texas Instruments C2000 real-time MCUs
  3. NXP MCX microcontrollers
  4. Infineon XMC microcontroller portfolio

Key Takeaways

  • Write the loop timing budget before choosing the MCU. Clock speed alone decides nothing.
  • The advanced timer or HRTIM decides the motor control question, because only it gives complementary outputs with hardware dead time and a centre-aligned counter.
  • A 20 kHz current loop on a 168 MHz Cortex-M4F costs about 8400 core cycles per iteration, which is enough for Clarke, Park, a PI controller and the PWM update.
  • Memory is sized by the bootloader scheme and the RTOS, not by the application. A and B update slots plus a bootloader need 300 kB of flash on a lean build.
  • Specify the temperature grade and the distributor. Grade -40 to 85 deg C parts cost more but a consumer-grade part in a 45 deg C cabinet is a false economy.

Leave a Reply