Skip to content

This software accompanies application note [AN12345], which describes how to use ctimer to generate center aligned PWM in MCX MCU.

License

Unknown, BSD-3-Clause licenses found

Licenses found

Unknown
LICENSE.txt
BSD-3-Clause
COPYING-BSD-3.txt
Notifications You must be signed in to change notification settings

nxp-appcodehub/an-mcxn947-ctimer-center-aligned-pwm

Repository files navigation

NXP Application Code Hub

How to use ctimer to generate center aligned PWM in MCX MCU

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.

Boards: FRDM-MCXN947

Categories: Motor Control

Peripherals: CLOCKS, GPIO, COUNTER, TIMER

Toolchains: MCUXpresso IDE

Table of Contents

  1. Software
  2. Hardware
  3. Setup
  4. Results
  5. Support
  6. Release Notes

1. Software

  • 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.

2. Hardware

  • Type-C USB cable
  • FRDM-MCXN947
  • Personal Computer
  • Logic device: Saleae logic pro16
  • Some Dupont wires

3. Setup

3.1 Step 1

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)

hardware

3.2 Step 2

  • Import the project to MCUXpresso IDE.
  1. Open MCUXpresso IDE, in the Quick Start Panel, choose Import from Application Code Hub.

  2. Enter the demo name in the search bar.

  3. Click Copy GitHub link, MCUXpresso IDE will automatically retrieve project attributes, then click Next>.

  4. 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.

4. Results

Reset the board, open the logic app on PC, and capture the timing as below.

5. Support

Provide URLs for help here.

Project Metadata

Board badge

Category badge

Peripheral badge Peripheral badge Peripheral badge Peripheral badge

Toolchain badge

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

Follow us on Youtube Follow us on LinkedIn Follow us on Facebook Follow us on Twitter

6. Release Notes

Version Description / Update Date
1.0 Initial release on Application Code Hub February 13th 2025
Trademarks and Service Marks: There are a number of proprietary logos, service marks, trademarks, slogans and product designations ("Marks") found on this Site. By making the Marks available on this Site, NXP is not granting you a license to use them in any fashion. Access to this Site does not confer upon you any license to the Marks under any of NXP or any third party's intellectual property rights. While NXP encourages others to link to our URL, no NXP trademark or service mark may be used as a hyperlink without NXP’s prior written permission. The following Marks are the property of NXP. This list is not comprehensive; the absence of a Mark from the list does not constitute a waiver of intellectual property rights established by NXP in a Mark.
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.

About

This software accompanies application note [AN12345], which describes how to use ctimer to generate center aligned PWM in MCX MCU.

Resources

License

Unknown, BSD-3-Clause licenses found

Licenses found

Unknown
LICENSE.txt
BSD-3-Clause
COPYING-BSD-3.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages