an-mc-pmsm-foc-2sh-s32k344
mc pmsm foc 2sh s32k344
README
NXP Application Code Hub
PMSM Motor Control Sensorless dual Shunt FOC on FRDM-A-S32K344
This example demonstrates a sensorless Field Oriented Control (FOC) implementation for Permanent Magnet Synchronous Motor (PMSM) using dual shunt current sensing on the NXP DEVKIT-MOTORGD and S32K344 microcontroller.
The demo is based on the AN13767 3-phase Sensorless PMSM Motor Control Kit with S32K344 using RTD Low Level API, more details about the implementation can be found in the application note.
The complete setup with FRDM-A-S32K344, DEVKIT-MOTORGD Shield and Sunrise motor is pictured below:

Boards: FRDM-A-S32K344, DEVKIT-MOTORGD
Categories: Motor Control
Peripherals: BCTU, eMIOS, ADC, PWM, SPI, UART
Toolchains: S32 Design Studio IDE
Table of Contents
1. Software and Tools
This example was developed using the FRDM Automotive Bundle for S32K3 + S32M27. To download and install the complete software and tools ecosystem, use the following link:
- FRDM Automotive S32K3 + S32M27 Board Installation Package
- Automotive Math and Motor Control Library (AMMCLib) Rev 1.1.45
- FreeMASTER Run-Time Debugging Tool
2. Hardware
- Personal Computer
- 12V Power Supply
- USB Type-C cable
- FRDM-A-S32K344

- DEVKIT-MOTORGD

- Sunrise Motor from BLDC-KIT

3. Setup
3.1 Import the project to S32 Design Studio IDE
- Open S32 Design Studio IDE, in the Dashboard Panel, choose Import project from Application Code Hub.

- Find the demo by searching: an-mc-pmsm-foc-2sh-s32k344
- Open the project, click the GitHub link, S32 Design Studio IDE will automatically retrieve project attributes, then click Next>.

- Select main branch and then click Next>.
- Select your local path for the repo in Destination->Directory: window. The S32 Design Studio IDE will clone the repo into this path, click Next>.
- Select Import existing Eclipse projects then click Next>.
- Select the project in this repo (only one project in this repo) then click Finish.
3.2 Generating, Building and Running the Example
-
In Project Explorer, right-click the project and select Update Code and Build Project. This will generate the configuration (Pins, Clocks, Peripherals), update the source code and build the project using the active configuration (e.g., Debug_FLASH). Make sure the build completes successfully and the *.elf file is generated without errors.
Press Yes in the SDK Component Management pop-up window to continue. -
Go to Debug and select Debug Configurations. There will be a debug configuration for this project:

Configuration Name Description ------------------------------- ----------------------- $(example)_debug_flash_pemicro Debug the FLASH configuration using PEmicro probeSelect the desired debug configuration and click on Debug. Now the perspective will change to the Debug Perspective. Use the controls to manage the program flow.
3.3 Connecting the Hardware
-
Before proceeding, the FRDM-A-S32K344 board requires modifications, the resistors listed in the table below must be changed:
Resistor Board Side Modification | R418, R414, R413 | Top | Add 0Ω jumper | Enable motor control connections | | R396, R397 | Bottom | Remove | Avoid I2C bus conflicts |
- On Top of FRDM-A-S32K344 board, Add 0 ohm resistors or jumpers to R418, R414, R413 to enable the motor control connections:

- On the bottom of FRDM-A-S32K344 board, Remove the R396, R397 resistors to avoid conflicts with the I2C bus: https://github.com/nxp-appcodehub/an-mc-pmsm-foc-2sh-s32k344/blob/HEAD/images/FRDM-A-S32K344-Resistor-Remove.jpg
- On Top of FRDM-A-S32K344 board, Add 0 ohm resistors or jumpers to R418, R414, R413 to enable the motor control connections:
-
Insert the DEVKIT-MOTORGD motor control shield on top of the FRDM-A-S32K344 board, check the pins alignment are correct and then press on the connectors firmly.
-
Check the location of User Buttons, RGB LED, 12 Vin DC power, USB Type-C connector, Motor Phases, Hall connector JP1: https://github.com/nxp-appcodehub/an-mc-pmsm-foc-2sh-s32k344/blob/HEAD/images/FRDM-A-S32K344-MC-TOP.JPG
- Connect 12V DC power supply to the board via the 12V power connector.
- Plug the USB Type-C cable to the board for debugging and communication.
- Insert the motor phases (A,B,C) to the DEVKIT-MOTORGD motor control shield.
- Plug-in the Hall sensor connector to JP1 on the board.
⚠️ Safety Warnings
IMPORTANT - Read before starting the motor:
- Ensure motor is mechanically secured before testing
- Keep hands and loose clothing away from rotating parts
- Verify correct power supply voltage (12V DC, max current rating)
- Ensure proper ventilation - motors can overheat
- Use emergency stop procedures when testing
- Disconnect power before making hardware changes
- Never exceed motor's rated speed/current specifications4. Results
- Open FreeMASTER Run-Time Debugging Tool and establish a connection to the target board via USB Type-C cable.
- Open FreeMASTER_control/S32K_PMSM_Sensorless.pmpx project file in FreeMASTER.
- Click on "GO" button to establish communication with the target board: https://github.com/nxp-appcodehub/an-mc-pmsm-foc-2sh-s32k344/blob/HEAD/images/FreeMASTER_Connect.png
- Go to App Control Tab and Press "ON" button to start the motor, set the Speed_Required value to the desired motor speed (1000RPM): https://github.com/nxp-appcodehub/an-mc-pmsm-foc-2sh-s32k344/blob/HEAD/images/FreeMASTER_Running.png
- Observe the motor iABC current waveforms in real-time on the FreeMASTER: https://github.com/nxp-appcodehub/an-mc-pmsm-foc-2sh-s32k344/blob/HEAD/images/FreeMASTER_Waveforms.png
5. FAQs
Common Issues and Solutions
Does FreeMASTER connect?
?????? NO ??? Check USB cable, COM port, firmware loaded
?????? YES ??? Is "Fault" displayed?
?????? YES ??? Check fault code in FreeMASTER ??? Faults & Trips tab
??? ?????? Overcurrent ??? Reduce current limit, check motor wiring
??? ?????? Overvoltage/Undervoltage ??? Check 12V supply is within range
??? ?????? Ia, Ib or Ic ??? Check that motor phase connections are correct
??? ?????? GD3000 ??? Check gate driver supply voltage and Status0 value
??? ?????? FOC ??? Verify motor shaft is free to rotate
?????? NO ??? Check "ON" button pressed, Speed_Required > 0-
After loading the project, there is a message "NXP GCC 10.2 compiler not found":
- Right-click on the project and select Quick Fix to install the required compiler:
https://github.com/nxp-appcodehub/an-mc-pmsm-foc-2sh-s32k344/blob/HEAD/images/S32DS_Qfix.png
- Alternatively, navigate to S32DS Extensions and Updates > NXP GCC 10.2 > Install and add the NXP GCC 10.2 compiler:
https://github.com/nxp-appcodehub/an-mc-pmsm-foc-2sh-s32k344/blob/HEAD/images/S32DS_GCC.png
-
After loading the project, there is a message "Path to collateral manifest does not exist ${S32K3xx_AMMCLIB}"
- Install AMMCLIB from S32DS Extensions and Updates > AMMCLIB for S32K3xx/S32M27x > Install
https://github.com/nxp-appcodehub/an-mc-pmsm-foc-2sh-s32k344/blob/HEAD/images/S32DS_AMMCLIB.png
6. Support
Project Metadata
Questions regarding the content/correctness of this example can be entered as Issues within this GitHub repository.
Note: For more general technical questions regarding NXP Microcontrollers and the difference in expected functionality, enter your questions on the NXP Community Forum
7. Release Notes
| Version | Description / Update | Date |
|---|---|---|
| 1.0 | Initial release on Application Code Hub | May 4th 2026 |
| 1.1 | Updated to FRDM Automotive S32K3 + S32M27 (RTD 7.0.1) | August 27th 2026 |


