Getting Started with the FRDM-K32L2A4S | NXP Semiconductors

Getting Started with the FRDM-K32L2A4S

Last Modified: 2022-12-28 10:40:00Supports FRDM-K32L2A4S Platform FRDM Development Board

Contents of this document

  • 1

    Plug It In
  • 2

    Get Software
  • 3

    Build, Run
  • 4

    Modify a SDK example
  • 5

    Learn

1. Plug It In

Let's take your FRDM-K32L2A4 for a test drive! You have the choice of watching the sequence in a short video or following the detailed actions listed below.

Video Player is loading.
Current Time 0:00
Duration 0:00
Loaded: 0%
Stream Type LIVE
Remaining Time 0:00
 
1x
  • Chapters
  • descriptions off, selected
  • captions off, selected

      1.1 Get familiar with the Board

      PLUG-IN-IT-FRDM-K32L2A4-1

      PLUG-IN-IT-FRDM-K32L2A4-1

      1.2 Attach the USB Cable

      Run the Out-of-Box Demo

      This bubble demo leverages the on board accelerometer. When the board is flat, the red and green LEDs are turned off, and when the board is tilted, the green or red LEDs gradually illuminate based on the degree of tilt on the X- and Y-axis.

      2. Get Software

      Video Player is loading.
      Current Time 0:00
      Duration 0:00
      Loaded: 0%
      Stream Type LIVE
      Remaining Time 0:00
       
      1x
      • Chapters
      • descriptions off, selected
      • captions off, selected

          2.1 Jump Start Your Design with the MCUXpresso SDK

          Want to learn more about SDK

          The MCUXpresso Software Development Kit (SDK) is complimentary and includes full source code under a permissive open-source license for all hardware abstraction and peripheral driver software.

          Click below to download a pre-configured Windows SDK release for the FRDM-K32L2A4S, which includes IDE support for MCUXpresso, Keil MDK, GCC ARM Embedded and IAR Embedded Workbench.

          You can also use the online SDK Builder to create a custom SDK package for the FRDM-K32L2A4S.

          2.2 Install your toolchain

          MCUXpresso IDE is development platform ecosystem from NXP. It provides an end-to-end solution enabling engineers to develop embedded applications from initial evaluation to final production.

          Want to use a different toolchain?

          No problem! The MCUXpresso SDK includes support for other tools such as IAR,Keil and command-line GCC.

          2.3 MCUXpresso Config Tools

          The MCUXpresso Config Tool is an integrated suite of configuration tools that guides users in creating new MCUXpresso SDK projects, and also provides pin and clock tools to generate initialization C code for custom board support, It is fully integrated into MCUXpresso or you can download a seperate tool.

          2.4 Serial terminal

          Many of the example applications output data over the MCU UART so you'll want to make sure that the driver for the board's virtual COM port is installed. Before you run the driver installer, you MUST have the board plugged into your PC.

          With the serial port driver installed, run your favorite terminal application to view the serial output from the MCU's UART. Configure the terminal to 115,200 baud rate, 8 data bits, no parity, and 1 stop bit. To determine the port number of the FRDM-K32L2A4S's virtual COM port, open the device manager and look under the "Ports" group.

          Not sure how to use a terminal application? Try one of these tutorials:

          MCUXpresso IDE Terminal Tutorial

          The most recent versions of MCUXpresso IDE count with a terminal emulation application. This tool can be used to display information sent from your NXP development platform's virtual serial port.

          1. Open the MCUXpresso IDE.
          2. Launch the MCUXpresso IDE terminal by clicking on the “Open a Terminal” button on the top of the IDE or press “Ctrl + Alt + Shift + T.”
          3. Select Serial Terminal.
          4. Configure the serial port settings (using the corresponding COM port number) to 115200 baud rate, 8 data bits, no parity and 1 stop bit, then press “OK” button.
          5. Verify that the connection is open. If connected, MCUXpresso IDE will look like the figure below at the Terminal view.
          6. You're ready to go

          Tera Term Tutorial

          Tera Term is a very popular open source terminal emulation application. This program can be used to display information sent from your NXP development platform's virtual serial port.

          1. Download Tera Term from SourceForge. After the download, run the installer and then return to this webpage to continue.
          2. Launch Tera Term. The first time it launches, it will show you the following dialog. Select the serial option. Assuming your board is plugged in, there should be a COM port automatically populated in the list.
          3. Configure the serial port settings (using the COM port number identified earlier) to 115200 baud rate, 8 data bits, no parity and 1 stop bit. To do this, go to Setup -> Serial Port and change the settings.
          4. Verify that the connection is open. If connected, Tera Term will show something like below in it's title bar.

          PuTTY Tutorial

          PuTTY is a popular terminal emulation application. This program can be used to display information sent from your NXP development platform's virtual serial port.

          1. Download PuTTY using the button below. After the download, run the installer and then return to this webpage to continue.
          2. Launch PuTTY by either double clicking on the *.exe file you downloaded or from the Start menu, depending on the type of download you selected.
          3. Configure In the window that launches, select the Serial radio button and enter the COM port number that you determined earlier. Also enter the baud rate, in this case 115200.
          4. Click Open to open the serial connection. Assuming the board is connected and you entered the correct COM port, the terminal window will open. If the configuration is not correct, PuTTY will alert you.
          5. You're ready to go

          3. Build, Run

          Video Player is loading.
          Current Time 0:00
          Duration 0:00
          Loaded: 0%
          Stream Type LIVE
          Remaining Time 0:00
           
          1x
          • Chapters
          • descriptions off, selected
          • captions off, selected
          • en (Main), selected

            3.1 Installing the SDK

            The MCUXpresso SDK comes with a long list of example applications code. To see what's available, browse to the SDK boards folder of your SDK installation and select FRDM-K32L2A4 (<SDK_Install_Directory> /boards/frdmk32l2as).

            To learn more about specific example code, open the readme.txt file in an example’s directory.

            3.2 Build, Run

            If one or more of the demo application or driver examples sounds interesting, you're probably wanting to know how you can build and debug yourself. The Getting Started with SDK guide provides easy, step-by-step instructions on how to configure, build, and debug demos for all toolchains supported by the SDK.

            Use the guide below to learn how to open, build and debug an example application using the MCUXpresso IDE

            Running a demo using MCUXpresso IDE

            1. Import the MCUXpresso SDK
              1. Open the MCUXpresso IDE and close the welcome page.
              2. Switch to the Installed SDKs view within the MCUXpresso IDE window
              3. Drag and drop the FRDM SDK (zipped) file into the Installed SDKs view.
              4. You will get the following pop-up. Click on OK to continue the import:
              5. The installed SDK will appear in the Installed SDKs view as shown below:
            2. Build an Example Application

              The following steps will guide you through opening the hello_world example.

              1. Find the Quickstart Panel in the lower left-hand corner.
              2. Then click on Import SDK examples(s)…
              3. Click on the frdmk32L2A board to select that you want to import an example that can run on that board, and then click on Next.
              4. Use the arrow button to expand the demo_apps category, and then click the checkbox next to hello_world to select that project. 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.
              5. Now build the project by clicking on the project name and then in the Quickstart Panel click on Build or press “Ctrl + b.”
              6. You can see the status of the build in the Console tab.
            3. Run an Example Application
              1. Now that the project has been compiled, you can now flash it to the board and run it.
              2. Make sure the FRDM-K32L2A4 board is plugged in and click on Debug in the Quickstart Panel.
              3. MCUXpresso IDE will probe for connected boards and should find the CMSIS-DAP debug probe that is part of the integrated OpenSDA circuit on the K32L2A4. Click on OK to continue.
              4. The firmware will be downloaded to the board, and the debugger started.
              5. Open a terminal program and connect to the COM port the board enumerated as. Configure the terminal with these settings:
                • 115200 baud rate.
                • No parity.
                • 8 data bits
                • 1 stop bit
              6. Start the application by clicking the "Resume" button:
              7. The hello_world application is now running, and a banner is displayed on the terminal. If this is not the case, check your terminal settings and connections.
              8. Use the controls in the menu bar to pause, step into, and step over instructions, and then stop the debugging session by click on the Terminate icon:

            Running a demo using IAR Embedded Workbench IDE

            1. Build an Example Application
            2. The following steps will guide you through opening the hello_world application. These steps may change slightly for other example applications as some of these applications may have additional layers of folders in their path.

              1. First unzip the previously downloaded SDK.
              2. If not already done, open the desired example application workspace. Most example application workspace files can be located using the following path:
              3. <install_dir>/boards/<sdk_board_name>/<example_type>/<application_name>/iar

                Using the hello_world demo as an example, the path is:

                <install_dir>/boards/frdmk32l2a4s/demo_apps/hello_world/iar
              4. Select the desired build target from the drop-down. For this example, select the “hello_world – Debug” target.
              5. To build the application, click the “Make” button, highlighted in red below.
              6. The build will complete without errors.
            3. Run an Example Application
            4. The FRDM-K32L2A4 board comes loaded with the mbed/CMSIS-DAP debug interface from the factory. If you have changed the debug OpenSDA application on your board, visit http://www.nxp.com/opensda for information on updating or restoring your board to the factory state.

              1. Connect the development platform to your PC via USB cable between the "SDAUSB" USB port on the board and the PC USB connector.
              2. Open the terminal application on the PC (such as PuTTY or Tera Term) and connect to the debug COM port you determined earlier. Configure the terminal with these settings:
                1. 115200 baud rate
                2. No parity
                3. 8 data bits
                4. 1 stop bit
              3. Click the "Download and Debug" button to download the application to the target.
              4. The application is then downloaded to the target and automatically runs to the main () function.
              5. Run the code by clicking the "Go" button to start the application.
              6. The hello_world application is now running, and a banner is displayed on the terminal. If this is not the case, check your terminal settings and connections.

            Running a demo using Keil® MDK/µVision®

            1. Install CMSIS device pack
            2. After the MDK tools are installed, Cortex® Microcontroller Software Interface Standard (CMSIS) device packs must be installed to fully support the device from a debug perspective. These packs include things such as memory map information, register definitions and flash programming algorithms. Follow these steps to install the appropriate CMSIS pack.

              1. Open the MDK IDE, which is called µVision. In the IDE, select the "Pack Installer" icon.
              2. In the Pack Installer window, search for “K32L2A4” to bring up the K32L2A4 family. Click on the K32L2A4 name, and then in the right-hand side you’ll see the NXP::FRDM-K32L2A4S_BSP pack. Click on the “Install” button next to the pack. This process requires an internet connection to successfully complete.
              3. After the installation finishes, close the Pack Installer window and return to the µVision IDE.
            3. Build the Example Application
            4. The following steps will guide you through opening the hello_world application. These steps may change slightly for other example applications as some of these applications may have additional layers of folders in their path.

              1. If not already done, open the desired demo application workspace in:
              2. <install_dir>/boards/<sdk_board_name>/<example_type>/<application_name>/mdk

                The workspace file is named <application_name>.uvmpw, so for this specific example, the actual path is:

                <install_dir>/boards/frdmk32l2a4s/demo_apps/hello_world/mdk/hello_world.uvmpw

              3. To build the demo project, select the "Rebuild" button, highlighted in red.
              4. The build will complete without errors.
            5. Run an Example Application
            6. The FRDM-K32L2A4 board comes loaded with the mbed/CMSIS-DAP debug interface from the factory. If you have changed the debug OpenSDA application on your board, visit http://www.nxp.com/opensda for information on updating or restoring your board to the factory state.

              1. Connect the development platform to your PC via USB cable between the "SDAUSB" USB port on the board and the PC USB connector.
              2. Open the terminal application on the PC (such as PuTTY or Tera Term) and connect to the debug COM port you determined earlier. Configure the terminal with these settings:
                1. 115200 baud rate
                2. No parity
                3. 8 data bits
                4. 1 stop bit
              3. After the application is properly built, click the "Download" button to download the application to the target.
              4. Click on “Start/Stop Debug Session” to open the debug view.
              5. Run the code by clicking the "Run" button to start the application.
              6. The hello_world application is now running, and a banner is displayed on the terminal. If this is not the case, check your terminal settings and connections.

            4. Modify a SDK example

            4.1 Clone an example project from MCUXpresso SDK

            Video Player is loading.
            Current Time 0:00
            Duration 4:58
            Loaded: 0%
            Stream Type LIVE
            Remaining Time 4:58
             
            1x
            • Chapters
            • descriptions off, selected
            • captions off, selected
            • en (Main), selected

              Option A: Use the MCUXpresso IDE to clone an example project.

              Use MCUXpresso IDE

              1. Build an Example Application
              2. The following steps will guide you through opening the gpio led output. This example takes turns to shine the led.

                1. Find the Quickstart Panel in the lower left-hand corner
                2. Then click on Import SDK examples(s)…
                3. Click on the frdmk32la4s board to select that you want to import an example that can run on that board, and then click on Next.
                4. Use the arrow button to expand the driver_examples category, then expand the gpio examples, click on the check box next to gpio_led_output 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.
                5. Click on the “frdmk32la4s_gpio_led_output” project in the Project Explorer view and build, compile, and run the demo as described previously.
                6. You should see the LEDs blinking on the board.
                7. Terminate the debug session.

              Option B: Use the MCUXpresso Config Tool to clone an existing MCUXpresso SDK example for use with third party IDEs.

              Use MCUXpresso Config Tools

              The following steps will guide you through opening the gpio led output. This example takes turns to shine the led.

              1. Open the MCUXpresso Config Tool.
              2. In the wizard that comes up, select the “Create a new configuration based on an SDK example or hello word project” radio button and click on Next.
              3. On the next screen, select the location of the MCUXpresso SDK that you had unzipped earlier. Then select the IDE that is being used. Note that only IDEs that were selected in the online SDK builder when the SDK was built will be available and click on clone select example.
              4. Then select the project to clone. For this example, we want to use the gpio led output project. You can filter for this by typing “gpio” in the filter box and then selecting the “gpio_led_output” example project. You can then also specify where to clone the project and the name. Then click on Finish.

              5. After cloning go to the directory you selected and open the project for your IDE. Import, compile, and run the project as done in previous sections.
              6. You should see the LEDs blinking on the board.
              7. Terminate the debug session.

              4.2 Use the Pin Tool

              p> Now, let’s use the Pins tool that is part of the MCUXpresso Config Tool to show how to add a new GPIO pin to your project to blink an LED.

              Use MCUXpresso IDE Pins Tools

              *Note: Previously, you had to clone an SDK project like in the previous step.
              1. To open pin tools in MCUXpresso IDE:
                1. Open the pins tool by right clicking on the “frdmk32l2a4s_gpio_led_output” project, and selecting “MCUXpresso Config Tools” and then “Open Pins”
                2. The pins tool should now display the pin configuration for the pwm project.
              2. To open pin tools in MCUXpresso Config tools:
                1. Open the MCUXpresso Config Tool.
                2. In the wizard that comes up, select the “Open existing configuration” radio button, then select the project that you had clone and click on Next.
                3. Open the pins tool by selecting Tools->Pins from the toolbar.
                4. The pins tool should now display the pin configuration for the pwm project.
              3. Use the pins tools to modify the gpio routed pin:
                1. We’ll use MCUXpresso IDE for the rest of the instructions, but the same steps can be done in MCUXpresso Config tools for third party IDEs. In the Pins view deselect the “Show not routed pins” checkbox to see only the routed pins, you also going to see the pins that are routed by default. 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.
                2. In the current configuration, PTE29 is routed as a GPIO toggle the red LED. For this example, we’ll use PTC4 instead to drive the green LED.
                3. Disable, PTE29 as a GPIO by clicking the “PTE29” field under the GPIO column. The pin will then be disabled (pin will no longer have check in box) and thus disappear from the list.
                4. Now, route PTC4 as a GPIO. First, select the “Show not routed pins” so that all the pins are displayed again. Then, search PTC4 in the pins view. Finally, click the box under the GPIO column “PTC4”. The box will highlight in green, and a check will appear next to the pin.
                5. 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.
                6. 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.

                  Note: The clocks files may also be tagged as being updated since the header has been changed.

                7. Now inside the IDE, open the gpio_led_output.c file.
                8. Change two #defines to tell the GPIO project to use the new PTC4 pin. Change from the red LED to the green.
                9. Build and download the project as done in the previous section.
                10. Run the application. You will now see the green LED blink!
                11. Terminate the debug session.

              4.3 Use the Clocks Tool

              Next use the Clocks tool that is part of the MCUXpresso Config Tool to change the clock settings and change the rate that the LED blinks.

              Use MCUXpresso Config Tools

              *Note: Previously, you had to clone an SDK project like in the past step.
              1. To open clock tools in MCUXpresso IDE:
                1. Open the Clock tool by right clicking on the “frdmk32l2a4s_gpio_led_output” project and selecting “MCUXpresso Config Tools” and then “Open Clocks”.
                2. The clock tool should now display the clock configuration for the project.
              2. To open clock tools in MCUXpresso Config tools:
                1. Open the MCUXpresso Config Tool.
                2. In the wizard that comes up, select the “Open existing configuration” radio button, then select the project that you had clone and click on Next.
                3. Open the clocks tool by selecting Tools->clocks from the toolbar.
                4. The clock tool should now display the clock configuration for the project.
              3. Use the clock tools to modify the system clock:
                1. We’ll use MCUXpresso IDE for the rest of the instructions, but the same steps can be done in MCUXpresso Config tools for third party IDEs. Switch to the Clocks Diagram view by clicking the tab in the upper left corner.
                2. Make sure that you are in the functional group called “BOARD_BootClockRun”.
                3. Change the core clock frequency by clicking in the Core Clock field and typing “12”. You’ll see all the other clock values automatically change as well to adjust to this slower speed. It will look like this when done:
                4. Now it’s time to implement these changes into the project by exporting the new updated clock_mux.c and clock_mux.h files that are generated by the Pins tool. Click on Update Project in the menu bar.
                5. 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 Clock tool. Click on “OK” to overwrite the new files into your project.

                  Note: The Pins files may also be tagged as being updated since the header has been changed.

                6. Build and download the project as done in the previous section.
                7. Run the application. The green LED should now be blinking at a much slower rate!
                8. Terminate the debug session.

              4.4 Success

              With the application modified, you will see the FRDM-K32L2A4 green LED slowly blinking. You can also view terminal output using the terminal program.

              5. Learn

              Explore beyond the FRDM-K32L2A4S by integrating other NXP solutions and software to your project and interact with our worldwide design community

              5.1 Sensors

              Explore the world with a full assortment of NXP sensor solutions. From accelerometers, pressure sensors, touch sensors, and many more, NXP has a sensor solution for your project. Find out more at http://nxp.com/sensors

              5.2 NFC

              Near Field Communication is a simple, intuitive technology that lets you interact securely with the world around you with a simple touch. Learn more about NXP’s NFC solutions at http://nxp.com/nfc

              5.3 Kinetis and MCUXpresso Communities

              p> Connect with other engineers and get expert advice on designing with LPC MCUs and MCUXpresso Software and Tools. Join the community discussion in one of our two dedicated communities: Kinetis MCU Community or MCUXpresso Software and Tools Community