How To: Create an MQX RTOS project with Processor Expert in Kinetis Design Studio IDE
(This is an update and extension of Derek Snell's post:MQX with KSDK and Processor Expert. Thanks Derek!)
There are a few different methods to get started with MQX RTOS for Kinetis SDK. One of which is using Kinetis Design Studio with Processor Expert. Processor Expert provides a graphical interface for configuring your project and adding useful software components.
Important Note #1: In the past, Processor Expert included MQX Lite and MQX components. With the release of the Kinetis SDK, there is a new MQX_KSDK component that is suitable for configuring the version of MQX RTOS that comes with the Kinetis SDK. Be sure to use the new component!
Important Note #2: New Kinetis Design Studio projects enabled with Kinetis SDK and Processor Expert use an Operating System Abstraction (OSA) component which is used to select which RTOS (or no RTOS – baremetal) option you are using. The OSA component will inherit in the selected RTOS component for you. So, don’t add in MQX_KSDK yourself. Let the OSA do it.
The following instructions are based on Kinetis SDK v1.1 and Kinetis Design Studio IDE v2.0
See section 5.2 in the Getting Started with Kinetis SDK guide.
Create a New Kinetis Design Studio Project
Select a Board (or Processor if you prefer - this changes the steps slightly.)
Choose Kinetis SDK and Processor Expert
Now you have a new Kinetis SDK project that is ready to be configured with Processor Expert.
In the Components window, under Components, open the OSA component
The Component Inspector window will now show you the Properties and Methods for that component.
From the OS dropdown list, choose MQX_KSDK as your OS
Now you need to set up the MQX_KSDK component for use in your project.
Open the MQX_KSDK component (inherited by the OSA component)
Select the Configuration parameters tab
In the Configuration set, you have the choice of MQX Lite and MQX Standard.
For this first example, I will chose MQX Lite.
MQX Lite is a light weight configuration of MQX RTOS offering a subset of capabilities. MQX Lite uses static memory allocation by default. If you want to use the RTCS TCP/IP stack, MFS file system, dynamic memory allocation, or some of the advanced features of MQX RTOS, use MQX Standard.
Now select the Shared components tab. You can see that it uses the DbgCs1 component for serial communications.
Click on the DbgCs1 component
You need to tell it which UART should be used for the DbgCs1 component (default serial port).
On the FRDM-K64F, UART 0 connects to the on-board debug circuit for virtual com port to the host PC. It is a bit confusing, but the signal names on the schematic, on the debug circuit side, say UART1_RX_TRGMCU and UART1_TX_TRGMCU
For Device, choose UART0. Then pick a baud rate – I chose 115200. Then select the Pins to be used. This uses the net names for the signals on the schematic.
For the selected baud rate 115200, I get an error that says that not all of the clock configurations of the system can support it.
Timing setting failed in Clock configuration 3 – it is impossible to set the following items: selected value
The CPU component comes pre-configured with 4 clock configurations that can be utilized in your system. These are very useful for switching between different clock modes in your application for power savings.
One of these clock configurations can’t do 115200, so I need to either change the baud rate or change the clock configuration. For this example, I am just going to delete the clock configuration because I am not going to use it.
Click the Cpu component.
Click Clock configurations
Then select Clock configuration 3. Click the down arrow v to lower it to the bottom of the list.
Then click – to remove.
There is one more configuration required in the DbgCs1 component. It is related to its inherited component, the fsl_uart_hal (hardware abstraction layer for the UART).
Click on the DbgCs1 component again.
Click on the arrow next to fsl_uart_hal.
And choose UART 0
Now you should have no errors.
Now, add some tasks. Processor Expert provides an OS_Task Component that will configure and generate the code framework for tasks.
Click Components Library.
Under Operating Systems, double click OS_Task to add tasks.
Click on the task components to configure them.
Click the Generate Processor Expert Code button.
The code will generate (update the configuration files for the Kinetis SDK). Wait until that finishes.
The MQX source code is here.
The task code is here.
Write your tasks! You can write native MQX RTOS function calls as well as Kinetis SDK driver and HAL calls. Just make sure to include the appropriate header file for the MQX or KSDK feature you use and add to the paths if necessary.
Now click the build button
Your new project will compile and link into a file for downloading and debugging on the target.
Hope this helps! Send me your feedback!