This code example demonstrates sensorless field-oriented control (FOC) for drone motors using the Infineon's PSOC™ Control C3 MCU and XENSIV™ TLx5572 TMR current sensor on the REF_ESC_48V_80A_FOC Electronic Speed Controller (ESC) reference design. This code example includes the sensorless PMSM FOC with 3-phase active sensing solution based on Rotor Field Oriented (RFO) control. Additionally this code demonstrates flightcontroller communication for transmitting throttle commands from the flightcontroller to the ESC using DSHOT600 protocol implementation
- 3.3 V 32-bit microcontroller Arm® Cortex®-M33 180 MHz PSOC™ Control C3 with 256 kB Flash and 64 kB RAM
- DShot600 interface for communication to drone flight controller
- High power density power stages using newest OptiMOS™ 8 technology, providing up to 2 kW power
- true 3-phase, non-invasive current sensing using XENSIV™ TMR-based current sensors
- Full motor control firmware framework for fast evaluation and adaption
Following products are featured by the reference hardware:
| Product | Description |
|---|---|
| PSC3M5FDS2LGQ1 | PSOC™ Control C3 - high performance microcontroller tailored for motor control |
| TLE5572-AE04E1-R-E0001 | XENSIV™ TLE5572 TMR-based current sensor with integrated op-amp |
| 1EDN7550B | EiceDRIVER™ 1EDN7550B TDI gate driver |
| ISC019N10NM8 | OptiMOS™ 8 power MOSFET 100 V, 1.9 mΩ in a SuperSO8 (5x6) package |
| TLS202B1MBV33 | Monolithic integrated post voltage regulator for load currents up to 150 mA |
- ESC reference design board: REF_ESC_48V_80A_FOC (link to board coming soon).
- Associated motor, with known motor parameters. This example code is tuned for the following motor: T-MOTOR MN1010 KV135
- Programmer and Debugger for the board e.g. XMC™ Link.
See the respective kit quick start guide for the hardware setup information. For details, see the User Manual (link to user manual coming soon) of the above reference design board.
- ModusToolbox™ with Eclipse version 2025.4 / 2025.8 and tools 3.5 / 3.7 version. See the ModusToolbox™ tools package installation guide for information about installing and configuring the tools package.
- ModusToolbox™ Motor Suite v2.6.1 / v 2.8.0.
- Programming language: C
- J-Link Software v8.40 or greater to allow the use of XMC™ Link to program the board and debug the software.
For a detailed versioning of the software packages please see image below.
Please note, that the firmware was only tested and confirmed with these software tool versions.
The debugger connection to the board is shown in the image below. Please make sure that 3V3, GND and the RESET pin are connected for correct operation.
Make sure that the debug settings of your debugger are set as follows:
The board should be recognized by the debugger and the firmware can be flashed.
- Clone the project repository into the local drive.
- Open the ModusToolbox™ IDE (e.g. Eclipse for ModusToolbox™ 2025.4) and import the project with the import wizard by pressing 'File' – 'Import…'.
- Select 'ModusToolbox™' – 'Import Existing Application In-Place' and press 'Next'.
- Find the Project Location by pressing 'Browse…', and select the project folder accordingly and press 'Finish'.
- Wait until the project is fully imported. Notice that additional folder 'mtb_shared' should be created (if there was none) in addition to the project folder itself, when the import is completed. This motor control project relies on the Infineon motor control library (current release is v3.0.0) provided in the ModusToolbox™ as shown inside the mtb_shared folder.
- Right click the project folder and select 'ModusToolbox™' followed by 'Library Manager 2...'.
- Press the 'Update' button
- When the Update is completed the sucessful messages should be displayed and the window can be closed.
If the update failed, try it again by repressing the 'Update' button. If this also fails, try to clean the project before trying it again.
- Ensure that the motor parameters are set correctly.
This code example contains the motor parameters of two example motors: MN1010 KV135 and MN501S KV240. If any of these motors are used, please define the MOTOR_TYPE in /configuration/hw-Config/HardwareIface.h accordingly. If different motor is used, please define MOTOR_TYPE to NOT_SPECIFIED, and continue to provide your own motor parameters.
The header file for the motor parameters is found in /configuration/motor-ctrl-lib-config/ParamConfig.h. Also, when the DC bus voltage differs from the pre-set 48 V, change MOTOR_CTRL_VDC_NOM_VOLT to scale for correct voltage readings.
- Additionally, two offsets have been introduced to provide fine correction in the DC bus voltage and temperature reading in relation to the ADC conversion.
If the DC bus voltage is not precise, the offset value can be adjusted in VBUS_VDC_OFFSET available in the same header file as above. Similarly, if the temperature reading is not precise, please adjust the offset value in TEMP_SENSOR_OFFSET.
- After updating the parameters, the firmware can be flashed to the device by first clicking the Project folder, followed by: Clean Project, and followed by: Build Project, and finally REF_ESC_48V_80A_FOC Program
- Open ModusToolbox™ Motor Suite v2.6.1 of v2.8.0 in the ModusToolbox™ IDE, and when the ModusToolbox™ Motor Suite window pops up, click on Cancel.
- Create a new project by selecting KIT_PSC3M5_CC2 (Dual), RFO as control method, and motor-ctrl-lib version 3.00, and click on New Project.
- Now the GUI control center will show up. Make sure that you are connected to the debugger (bottom right corner). On the bottom right panel there are icons with different functionality.
From left to right:
i) "Write Parameters" allows you to update parameter changes in the GUI to the MCU's flash memory.
ii) "Flash Firmware" allows flashing a new .hex file to the MCU.
iii) "Select ELF file" maps symbols from the .elf file to the GUI.
iv) "Read Device" reads current parameters and updates the GUI.
It is important to use the correct .elf as well as .hex files to maintain correct GUI performance. If firmware was already flashed to the MCU within ModusToolbox™ IDE, ensure correct symbol mapping by performing "Select ELF file". Point to the target .elf file of your project in the /build/last_config folder and the GUI will update.
- In order to run the motor, change to the "Test Bench" view. The test bench provides live data and machine state information. Check if the bus voltage is displayed correctly. Also check that the machine state is in "Brake Boot" mode when the Drive is "Enabled".
There should not be any Faults displayed and Temperature measured is in the range of ~20 degree C.
- The code example is set to speed control with alignment mode. Therefore, run the motor by setting a target speed (e.g. 20%) and the machine will transition to "Speed CL" state and the motor will spin.
To investigate data while operation, ModusToolbox™ Motor Suite features an oscilloscope function. The icon is found on the top right corner.
- The oscilloscope displays phase currents as well as electrical angle estimates from the observer. Successful operation should display phase currents and phase angle as shown in the picture below.
For direct evaluation of the motor control library it is recommended to use ModusToolbox™ Motor Suite. ModusToolbox™ Motor Suite allows real-time data monitoring using oscilloscope functions as well as easy change of control parameters written to the MCUs flash memory.
The code example implements a DShot600 protocol decoder which allows the use of any off-the-shelf flightcontroller stacks such as Pixhawk 6. The main operation of the decoder is found in the function FC_PWM_COUNTER_IRQ_RunISR() within MCU.c.
On the board, there are two DSHOT GPIO pins available which can be used in combination with the flight controller for speed control. This code example makes use of DS1 pin, which is connected to MCU Port 7[2].
Please refer to this file for more details on how to test this board using Dshot600 in communication with a flight controller to rotate a motor.
Infineon provides a wealth of data at www.infineon.com to help you select the right device, and quickly and effectively integrate it into your design.
All referenced product or service names and trademarks are the property of their respective owners.
The Bluetooth® word mark and logos are registered trademarks owned by Bluetooth SIG, Inc., and any use of such marks by Infineon is under license.
PSOC™, formerly known as PSoC™, is a trademark of Infineon Technologies. Any references to PSoC™ in this document or others shall be deemed to refer to PSOC™.
© Cypress Semiconductor Corporation, 2025. This document is the property of Cypress Semiconductor Corporation, an Infineon Technologies company, and its affiliates ("Cypress"). This document, including any software or firmware included or referenced in this document ("Software"), is owned by Cypress under the intellectual property laws and treaties of the United States and other countries worldwide. Cypress reserves all rights under such laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights, trademarks, or other intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with Cypress governing the use of the Software, then Cypress hereby grants you a personal, non-exclusive, nontransferable license (without the right to sublicense) (1) under its copyright rights in the Software (a) for Software provided in source code form, to modify and reproduce the Software solely for use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in binary code form externally to end users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units, and (2) under those claims of Cypress's patents that are infringed by the Software (as provided by Cypress, unmodified) to make, use, distribute, and import the Software solely for use with Cypress hardware products. Any other use, reproduction, modification, translation, or compilation of the Software is prohibited.
TO THE EXTENT PERMITTED BY APPLICABLE LAW, CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS DOCUMENT OR ANY SOFTWARE OR ACCOMPANYING HARDWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. No computing device can be absolutely secure. Therefore, despite security measures implemented in Cypress hardware or software products, Cypress shall have no liability arising out of any security breach, such as unauthorized access to or use of a Cypress product. CYPRESS DOES NOT REPRESENT, WARRANT, OR GUARANTEE THAT CYPRESS PRODUCTS, OR SYSTEMS CREATED USING CYPRESS PRODUCTS, WILL BE FREE FROM CORRUPTION, ATTACK, VIRUSES, INTERFERENCE, HACKING, DATA LOSS OR THEFT, OR OTHER SECURITY INTRUSION (collectively, "Security Breach"). Cypress disclaims any liability relating to any Security Breach, and you shall and hereby do release Cypress from any claim, damage, or other liability arising from any Security Breach. In addition, the products described in these materials may contain design defects or errors known as errata which may cause the product to deviate from published specifications. To the extent permitted by applicable law, Cypress reserves the right to make changes to this document without further notice. Cypress does not assume any liability arising out of the application or use of any product or circuit described in this document. Any information provided in this document, including any sample design information or programming code, is provided only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and safety of any application made of this information and any resulting product. "High-Risk Device" means any device or system whose failure could cause personal injury, death, or property damage. Examples of High-Risk Devices are weapons, nuclear installations, surgical implants, and other medical devices. "Critical Component" means any component of a High-Risk Device whose failure to perform can be reasonably expected to cause, directly or indirectly, the failure of the High-Risk Device, or to affect its safety or effectiveness. Cypress is not liable, in whole or in part, and you shall and hereby do release Cypress from any claim, damage, or other liability arising from any use of a Cypress product as a Critical Component in a High-Risk Device. You shall indemnify and hold Cypress, including its affiliates, and its directors, officers, employees, agents, distributors, and assigns harmless from and against all claims, costs, damages, and expenses, arising out of any claim, including claims for product liability, personal injury or death, or property damage arising from any use of a Cypress product as a Critical Component in a High-Risk Device. Cypress products are not intended or authorized for use as a Critical Component in any High-Risk Device except to the limited extent that (i) Cypress's published data sheet for the product explicitly states Cypress has qualified the product for use in a specific High-Risk Device, or (ii) Cypress has given you advance written authorization to use the product as a Critical Component in the specific High-Risk Device and you have signed a separate indemnification agreement.
Cypress, the Cypress logo, and combinations thereof, ModusToolbox, PSoC, CAPSENSE, EZ-USB, F-RAM, and TRAVEO are trademarks or registered trademarks of Cypress or a subsidiary of Cypress in the United States or in other countries. For a more complete list of Cypress trademarks, visit www.infineon.com. Other names and brands may be claimed as property of their respective owners.