An example to use MCUXpresso Pins Tool in a FreeRTOS project

cancel
Showing results for 
Search instead for 
Did you mean: 

An example to use MCUXpresso Pins Tool in a FreeRTOS project

An example to use MCUXpresso Pins Tool in a FreeRTOS project

MCUXpresso Pins Tool allows you to configure pin routing and generates ‘pin_mux.c & h’ source files. This article describes how to configure Pins in a FreeRTOS project with MCUXpresso pins tool.  In this example, pin PTC9 on Freedom-k66 board is configured.

 

Software and Tools

In this article, I’m using the following:

MCUXpresso IDE 10.2.1   www.nxp.com/mcuxpresso

MCUXpresso SDK 2.4.1 for  Frdm-k66f  board.  With Amazon FreeRTOS v10 .You can get it from https://mcuxpresso.nxp.com

FRDM-K66 board www.nxp.com/frdm-k66f

First, we need to have a working FreeRTOS project. Here we import the freertos_hello example into MCUXpresso IDE workspace.

To open the tool, simply right click on the project in Project Explorer and select the appropriate open command.

pastedImage_1.png

Then we can see the pin table, peripheral signals, package/pinout view, Routed pins view, generated code view.

pastedImage_2.png

pastedImage_3.png

Basic configuration can be done in either of these views Pins, Peripheral Signals or package. More advanced settings can be adjusted in Routed Pins view.

Beginning with Peripheral selection

In the Pins view on the left find a pin and peripheral signal in the table and configure the routing by clicking on the signal cell.

 

In this example, select PTC9.  Click into the cells to make them ‘green’

Select PTC9 on the Peripherals signals view,

pastedImage_4.png

Routed Pins configure

Route the selected signal to the desired pin,and configure it in the Routed Pins view.

It is possible to easily identify routed pins/peripherals in the package using highlighting. By default, the current selection (pin/peripheral) is highlighted in the package view.

State Indicator of Pin Tool

Green indicates pin/peripheral is routed

Yellow indicates pin/peripheral is currently selected

Red indicates an error

Light grey indicates pin/peripheral is available but is not currently routed.

It is also possible to configure the pin electrical features. Use the table drop down menu to configure the pin. To configure pins, start from left to right—select the peripheral first, then select required signal, and finally select the routed pin.

pastedImage_6.png

Code generation

 The Pins Tool automatically generates the source code for pin_mux.c and pin_mux.h on the right panel of the Code Preview view.

pastedImage_8.png

The configuration will be saved into .mex file, see picture below

pastedImage_9.png

Export the code.

 

You can now copy-paste the content of the sources to the application and IDE. Alternatively, you can export the generated files. To export the files, select the menu  Export

pastedImage_10.png

Click Next and specify the directory, Click Finish to export the files.

Integrate code the FreeRTOS task

In the source code, Board_InitBootPins() calls initial code in pin_mux.c/h

In hello world task, we toggle the configured pin

/*!

 * @brief Task responsible for printing of "Hello world." message.

 */

static void hello_task(void *pvParameters)

{

    for (;;)

    {

        PRINTF("Hello world.\r\n");

        /* Toggle LED. */

        GPIO_PortToggle(BOARD_LED_GPIO, 1U << BOARD_LED_GPIO_PIN);

        vTaskDelay(200);

    }

}

 

Then run the example, we can see LED is toggled every 200ms.

 

For information about how to create an FreeRTOS project with MCUXpresso IDE, please see the following document

https://community.nxp.com/docs/DOC-341972 

For information about configuring with MCUXpresso peripheral tool in an FreeRTOS project, please see the following document.

https://community.nxp.com/docs/DOC-341986

Version history
Revision #:
1 of 1
Last update:
‎11-06-2018 10:49 PM
Updated by: