Defining tasks using Processor Expert

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Defining tasks using Processor Expert

Jump to solution
2,576 Views
davepfaltzgraff
Senior Contributor I

I have an MQX_lite project that was defined using Processor Expert (PE). I have one task - blink an LED.

With the code that's generated, the task never runs. How can I define the set of auto-start tasks using PE? This would be preferred.

If I need to do it manually, where would it go in this snippet of main()?

====

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

PE_low_level_init();

  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */

  /* For example: for(;;) { } */

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/

  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/

  #ifdef PEX_RTOS_START

    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */

  #endif

  /*** End of RTOS startup code.  ***/

  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/

  for(;;){}

====

As it is now, the execution goes into PEX_RTOS_START() and never returns.

Thanks.

0 Kudos
1 Solution
1,152 Views
DavidS
NXP Employee
NXP Employee

Hi David,

There were several issues with the project.  I think it stemmed from initially having the project set for KSDK_MQX and generating code and working with PE MQX components.

I went in and added a OS_Task component after verifying that the osa1 component did have MQXLite selected.

I added your Blue LED goggle code to that new os_tasks.c file in the Sources folder.

I also updated two locations that thought UART2 was the UART to use on the FRDM-K22F.  Search"//DES" to find locations and comments.

I also added a debug_printf() call in the Blue LED toggle code.

I also noticed you left the default clocking to configuration 0 (Kinetis devices boot using internal IRC slow clock and use FFL to bump speed to ~20.xxxMHz).

You have the UART baud at 9600 as well.

If you change the clock configuration to 1 (Max setting) you can bump up the baud easily to 115200.

I think it would be good for you to review the following post to check your project creation steps:

How To: Create an MQX RTOS project with Processor Expert in Kinetis Design Studio IDE

Yes it is for FRDM-K64F but the main difference is for FRDM-K22F the UART is UART1 for VCOM and FRDM-K64F uses UART0.

Updated project/ZIP file attached.

Regard,

David

View solution in original post

0 Kudos
15 Replies
1,152 Views
DavidS
NXP Employee
NXP Employee

Hi David,

To add to Sol's response.

In your project folder, open the Sources folder.  It should contain os_tasks.c that will contain the OS_Task component generated code.

Add your code to blink LED into the task.  "main()" is not the right location.

Regards,

David

0 Kudos
1,152 Views
davepfaltzgraff
Senior Contributor I

Hi David,

That's where my task is. My question was: How can I get it to run under MQX? (See the details in my response to Soledad.)

It may be that I have some configuration combination that's not complete, but everyting seems to be there other than kicking off the tasks themselves.

Thanks

0 Kudos
1,152 Views
DavidS
NXP Employee
NXP Employee

Hi David,

What is the priority of the task priority set in the OS_Task component?

If you left it as default, then here is the workaround:

What's mean - assertion "!status" failed: file "C:/Freescale/KSDK_1.1

Regards,

David

0 Kudos
1,152 Views
davepfaltzgraff
Senior Contributor I

I left it at the default, but it is set to 8, not 32 as described in the other ticket. Also, I do not get the=at error message.

My system comes up and runs MQX. It just does execute my task. I set a breakpoint in the task and never get there. Whenever I stop execution, the system is in the  idle task.

0 Kudos
1,152 Views
DavidS
NXP Employee
NXP Employee

Can you clean the project, zip it, and attach it?

Seeing it will help.

Regards,

David

Sent from my iPhone

0 Kudos
1,152 Views
davepfaltzgraff
Senior Contributor I

I hope this is what you're looking for. I'm fairly new to KDS and I'm

still learning my way around. So, if it's not what you want, just let me

know.

Thanks,

Dave

0 Kudos
1,153 Views
DavidS
NXP Employee
NXP Employee

Hi David,

There were several issues with the project.  I think it stemmed from initially having the project set for KSDK_MQX and generating code and working with PE MQX components.

I went in and added a OS_Task component after verifying that the osa1 component did have MQXLite selected.

I added your Blue LED goggle code to that new os_tasks.c file in the Sources folder.

I also updated two locations that thought UART2 was the UART to use on the FRDM-K22F.  Search"//DES" to find locations and comments.

I also added a debug_printf() call in the Blue LED toggle code.

I also noticed you left the default clocking to configuration 0 (Kinetis devices boot using internal IRC slow clock and use FFL to bump speed to ~20.xxxMHz).

You have the UART baud at 9600 as well.

If you change the clock configuration to 1 (Max setting) you can bump up the baud easily to 115200.

I think it would be good for you to review the following post to check your project creation steps:

How To: Create an MQX RTOS project with Processor Expert in Kinetis Design Studio IDE

Yes it is for FRDM-K64F but the main difference is for FRDM-K22F the UART is UART1 for VCOM and FRDM-K64F uses UART0.

Updated project/ZIP file attached.

Regard,

David

0 Kudos
1,152 Views
davepfaltzgraff
Senior Contributor I

More information on the above.

First I read down to the MQX_Standard part and decided to try it. It worked. So, that's out of the way.

However, I then changed debug_printf() to just printf() as the first was undefined. Then I set the baud rate for UART1 to 9600. I got signal at J2-18 but the display was screwy until I set the baud rate to 115200. Then I got clear output.

I went back and changed the baud rate for UART1 and it still ran at 115200. I must be missing something there, but at least I'm operational.

Thanks

0 Kudos
1,152 Views
DavidS
NXP Employee
NXP Employee

Hi David,

I would not recommend using the same project to switch back and forth of using MQX and MQXLite.

Best to have separate projects.

For accessing a filesystem we have existing examples within the KSDK1.1.0 path.

MQX MFS examples at: C:\Freescale\KSDK_1.1.0\filesystem\mfs\examples .

We also have examples for MQX (non-PE).

Please review documents: C:\Freescale\KSDK_1.1.0\rtos\mqx\doc

Especially the Getting Started with Freescale MQX RTOS for Kinetis SDK.pdf

Once MQX libraries and platform library compiled, then test UART with C:\Freescale\KSDK_1.1.0\rtos\mqx\mqx\examples\hello MQX application project.

Please note KSDK1.1.0 is very full featured and can be configured to your needs but since it can be used for baremetal, using PE solo, KSDK+PE, KSDK+PE+MQX[|Lite], KSDK+MQX, etc (meaning other OS's too) it takes time and practice and lots of reading and playing around to master (I'm not there yet either) getting what you want.  With time FSL wants to make this process even easier.

Regards,

David

0 Kudos
1,152 Views
davepfaltzgraff
Senior Contributor I

Hi David,

I appreciate your comments. First a little background... I really like the ARM architecture and was introduced to it via the TI Stellaris line a few years ago. I started using it only to have TI yank the rug out by discontinuing it in favor of a "new and improved" replacement. Naturally those projects went dormant. (One is still slightly alive, but since TI wants a licensing fee for their IDE, it's doubtful that it will come back to what it could have been. I have trouble trying to justify a $500 fee to support three boards in the field!)

When I heard about the FRDM-K22F seminar, I jumped on it. For the volume that I do as an independent consultant (http://PitchforkSolutions.com), I can afford the cost of the KSD IDE! I also liked the integration of the PE and the KSDK. TI's level was OK for me, but what Freescale was offering was much better and I was anxious to discover more. So, I was a little frustrated at the beginning with everything leading up to: "Wait for the release in Q4." I almost dropped it then as the product was not as mature as was presented at the seminar. (Your sales pitch can only do so much in 6 hours.)

When the release came out in mid-Decmeber, I downloaded it and went through all of the non-RTOS examples that I could on my FRDM-K22F. Now I was ready to try the PE and KSDK. I explored some of the examples in the KSDK (UART and USB host), but it seemed to me that PE had not been used. This was disappointing to me as the PE would allow me to rapidly migrate (evolve) my designs from one project to another. That's what lead me to the current effort - try to get the whole shebang to work together with true integration.

For many of my projects, the file system is important, so my original intent was to use the full MQX. Since I could not find clear documentation that covered the full combination is KDS, PE and KSDK, I had to stumble. I found stale documentation that took me down blind alleys and that's how I ended up with the mess that I uploaded. Now, I know a little more. I can respond to your first recommendation in that my intent is to stay with MQX_Standard. The fact that the debug port is always 115200 baud is no big deal right now as it's only for me. (Note I tried other baud rates like 2400 and it always runs at 115200. So that may be a bug buried somewhere in PE.)

I looked at the filesystem examples you suggested and the only one for the FRDM-K22F is the RAMdisk example. When I pulled that up, I noted that the PE was not used for that. I think you can see where I'm headed here. As a designer, involved with both hardware and software, my niche in life is being able to respond quickly to a customer's request for a fast and solid solution. I need to be able to pick a board, specify it's configuration and add software functionality as though they were hardware components. Need a filesystem for logging? Click, OK, got that. Need an RTC (real time clock) for time stamping the data? Click, OK, got that. Need I2C to a peripheral? Click, OK, got that. Etc.

In the past, the only designs I've built with a filesystem have been with the stack offered by Microchip. It filled the requirement most of the time, but was too slow for others. I am continuing to work with the FRDM-K22F as that last project was based on an I2S audio interface and I saw that it's on the FRDM-K22F board. I've populated the board with the required components and will continue working on it. Whether or not I stay with the Kinetis line will depend on the level of frustration I encounter along the way. I personally believe that Freescale is taking the right path and I sincerely hope they succeed in the biggest way. No, it's not an Arduino. If that's what I wanted, I wouldn't be here to begin with. At the same time it's not bare bones (name any processor here), because I've been there since the beginning with the 8080. (Been there, done that, and the T-Shirt's worn out!)

Please share with anybody interested in what's happening out in the "user world". I would welcome the opportunity to become more than just an end user who complains when something doesn't work.

Thanks for your help and for listening.

Dave

0 Kudos
1,153 Views
soledad
NXP Employee
NXP Employee

  Re: What would be involved in porting the SAI demo over to the FRDM-K22F platform?

  Oralia Soledad Godinez Vega Employee

 

 

Hello David,

You can use Freescale MQX RTOS 4.1 for the FRDM-K22F, you can download from the below link:

FRDM-K22F|Freedom Development Board|Kinetis|Freescale

After install it, you can find a SAI example located at the path: C:\Freescale\Freescale_MQX_4_1_FRDMK22F120M\mqx\examples\sai_dma_demo

In addition you can find the application note "MQX_Writing_Your_First_Application"  at the path: C:\Freescale\Freescale_MQX_4_1_FRDMK22F120M\doc\mqx  the purpose of this Application Note is to provide:

  • Information that enables developers to start developing their first application on Freescale MQX RTOS quickly and easily.
  • Basic understanding how to develop Freescale MQX applications.


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,153 Views
davepfaltzgraff
Senior Contributor I

Hi David,

Just wanted to get back to you and say that the UART is not operational. I went back and checked all the values and they seemed OK - even tried changing the baud rate. But that didn't change things.

Getting out an oscilloscope, I don't see anything on the Tx (J2-18) - just flat-lined at 0V.

What can I check (and where) to debug this?

Thanks

0 Kudos
1,153 Views
davepfaltzgraff
Senior Contributor I

Hi David,

OK. That certainly got me on my way. I wish someone had pointed me to the "How To" article earlier. It would have saved me a lot of frustration. I had started with MQX with KSDK and Processor Expert which was written before the final release and lead me astray.

I don't have the debug serial working yet, but I need to explore that some more. It is most likely on the PC end. (Just FYI, I chose 9600 baud as a lot of my clients like to work there.)

One question I have is: Since one of my objectives is to incorporate a file system. What's involved in going from MQX_lite to the full MQX? Isn't there some consideration for how the serial debug is handled?

0 Kudos
1,153 Views
soledad
NXP Employee
NXP Employee

Hello David,

Please check the below document (page 3), you can find how to modify the attributes of each task in the

Component Inspector view.

How to use MQX performance tool and TAD in MQX Lite


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,153 Views
davepfaltzgraff
Senior Contributor I

I should mention that I'm using KDS (2.0.0) with KSDK (1.1.0) and Processor Expert 2.0.0.RT6_b1444-1070. (As far as I know, everything is the latest.)

In these circumstances, the menu PE configuration menu is considerably different than what you show. My component view is roughly:

    Generator Configurations

    OSs

        osa1:fsl_os_abstraction

            mqx_ksdk:MQX_KSDK

    Processors

        Cpu:MK22FN512VLH12

    Components

        Referenced Components

            intMan1:fsl_interrupt_manager

            clockMan1:fsl_clock_manager

            DbgCs1:fsl_debug_console

        pin_init:PinSettings

        FlashBue:MQX_KSDK_Task

        gpio:fsl_gpiio

Where "FlashBlue()" is the task I've written. Note that the positions in this view have been determined entirely by PE.

When I open mqxksdk:MQX:KSDK in the Component inspector, under the "Configuration parameters" tab, "MQX Lite" was selected for me, but I was not able to determine how to setup the tasks to actually run.

0 Kudos