Clone an Example Project from MCUXpresso IDE
The following steps will guide you through the manipulation of the general-purpose outputs. The example sets up a CTimer to generate a PWM signal and change between two LEDs.
- Find the Quickstart Panel in the lower left-hand corner and click on Import SDK example(s)
Sabina_Bruce_14-1767120564749.png
- Click on the FRDM-MCXN947 board to select that you want to import an example that can run on that board, and then click on Next
Sabina_Bruce_15-1767120575767.png
- Use the arrow button to expand the
driver_examples category, then expand the ctimer examples, click on the check box next to ctimer_match_interrupt_example to select it. To use the UART for printing (instead of the default semihosting), Select UART as the SDK Debug Console checkbox under the project options. Then, click on Finish
Sabina_Bruce_16-1767120587691.png
- Click on the
“frdmmcxn947_ctimer_match_interrupt_example” project in the Project Explorer View and build, compile, and run the demo as described in the previous section
Sabina_Bruce_17-1767120603466.png
- You should see the BLUE and RED LED changing back and forth
- Terminate the debug session
Use MCUXpresso IDE Pins Tools to Modify Example
Note: Previously, you had to clone an SDK project like in the previous step.
- Open the pins tool by selecting “ConfigTools” on the top right hand of the file explorer window and then select “ Open Pins”
Sabina_Bruce_2-1767120490131.png
- The pins tool should now display the pin configuration for the ctimer project
Sabina_Bruce_3-1767120490074.png
- In the Pins view deselect “Show dedicated pins” and “Show no routed pins” checkboxes to see only the routed pins. Routed pins have a check in a green box next to the pin name. The functions selected for each routed pin are highlighted in green
Sabina_Bruce_4-1767120490861.png
- In the current configuration, PIO3_2 and PIO3_3 are routed as the outputs of the CTimer. Let’s add a third Ctimer Match output and enable the Green LED
- Select “Show no routed pins” to see the other options. To enable the third Ctimer Match Output, browse the column for Ctimer and select and output. In this example, we will select, Ctimer4 Match 2 on PIO3_6. Select the item in the Ctimer column to enable
Sabina_Bruce_5-1767120490102.png
- Now, let’s route the Green LED. In the search box type “green” so that the routed pin for this LED is shown. Finally, click the box under the GPIO column. The box will highlight in green, and a check will appear next to the pin
Sabina_Bruce_6-1767120489892.png
- Next configure the GPIO pin as an output in the “Routing Details” window
Sabina_Bruce_7-1767120490064.png
- Now it’s time to implement these changes into the project by exporting the new updated pin_mux.c and pin_mux.h files that are generated by the Pins tool. Click on Update Project in the menu bar
Sabina_Bruce_8-1767120490018.png
- The screen that pops up will show the files that are changing and you can click on “diff” to see the difference between the current file and the new file generated by the Pins tool. Click on “OK” to overwrite the new files into your project
Sabina_Bruce_9-1767120490120.png
- Let’s add some additional code to the example. Open
simple_match_interrupt.c file and add the following macros for the third ctimer output.
Sabina_Bruce_10-1767120489936.png
- Add the Green LED functions as well.
Sabina_Bruce_11-1767120491994.png
- Some additional code to be implemented will be the third ctimer’s callback, this can be copied from
ctimer_match1_callback and modify the content to match2. To be able to visually identify the new ctimer, we will remove one of the previous ctimers as shown
Sabina_Bruce_12-1767120492171.png
- The main function will need to include the initialization of both the Green LED and the Ctimer
Sabina_Bruce_13-1767120490811.png
- Build and download the project as done in the previous section
- Run the application. You should now see the Green and Blue LED blinking back and forth
- Terminate the debug session