This software accompanies application note [AN12345], which describes how to use ctimer to generate center aligned PWM in MCX MCU.
The MCX series MCUs typically contain 3-5 Ctimers, which implement general timer functions. A CTIMER can optionally generate an interrupt or perform other actions at specified timer values based on the settings of Match (MR0 - MR3). Each CTIMER also includes capture input pins to capture the timer value when an input signal transitions, optionally generating an interrupt. In PWM mode, three match registers can be used to provide a single-edge controlled PWM output on the match output pins. One match register is used to control the PWM cycle length.
This software mainly describes how to use two Ctimers and four DMA channels to implement a pair of complementary PWM waveforms with dead-time control, which is commonly used in motor control.
- MCUXpresso IDE V11.10 or later.
- SDK_2_16_000_FRDM-MCXN947
- MCUXpresso for Visual Studio Code: This example supports MCUXpresso for Visual Studio Code, for more information about how to use Visual Studio Code please refer here.
- Type-C USB cable
- FRDM-MCXN947
- Personal Computer
- Logic device: Saleae logic pro16
- Some Dupont wires
Connect logic device to FRDM-MCXN947 with some DuPont wires, as shown below:
PWM_H signal pin: PIO2_10 (J8[15] on board)
PWM_L signal pin: PIO2_11 (J8[16] on board)
- Import the project to MCUXpresso IDE.
-
Open MCUXpresso IDE, in the Quick Start Panel, choose Import from Application Code Hub.
-
Enter the demo name in the search bar.
-
Click Copy GitHub link, MCUXpresso IDE will automatically retrieve project attributes, then click Next>.
-
Select main branch and then click Next>, Select the MCUXpresso project, click Finish button to complete import.
- Connect the micro USB cable between the PC host and the USB port (J17) on the board.
- Compile and download to the board.
- Reset and run.
Reset the board, open the logic app on PC, and capture the timing as below.
Provide URLs for help here.
Questions regarding the content/correctness of this example can be entered as Issues within this GitHub repository.
Warning: For more general technical questions regarding NXP Microcontrollers and the difference in expected functionality, enter your questions on the NXP Community Forum
Version | Description / Update | Date |
---|---|---|
1.0 | Initial release on Application Code Hub | February 13th 2025 |
NXP, the NXP logo, NXP SECURE CONNECTIONS FOR A SMARTER WORLD, Airfast, Altivec, ByLink, CodeWarrior, ColdFire, ColdFire+, CoolFlux, CoolFlux DSP, DESFire, EdgeLock, EdgeScale, EdgeVerse, elQ, Embrace, Freescale, GreenChip, HITAG, ICODE and I-CODE, Immersiv3D, I2C-bus logo , JCOP, Kinetis, Layerscape, MagniV, Mantis, MCCI, MIFARE, MIFARE Classic, MIFARE FleX, MIFARE4Mobile, MIFARE Plus, MIFARE Ultralight, MiGLO, MOBILEGT, NTAG, PEG, Plus X, POR, PowerQUICC, Processor Expert, QorIQ, QorIQ Qonverge, RoadLink wordmark and logo, SafeAssure, SafeAssure logo , SmartLX, SmartMX, StarCore, Symphony, Tower, TriMedia, Trimension, UCODE, VortiQa, Vybrid are trademarks of NXP B.V. All other product or service names are the property of their respective owners. © 2021 NXP B.V.