Problem with OS task events using freeRTOS.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problem with OS task events using freeRTOS.

ソリューションへジャンプ
3,726件の閲覧回数
joebirch
Contributor III

I cannot get task events to work. I am trying to signal between tasks

 

I have a very simple example with 2 tasks.

Task2 is waiting on an event.

Task1 sends the event.

 

I am using KDS 3.0, KSDK 1.2 on a FRDM_K22, gcc

The FreeRTOS version is 8.0.0 which comes with KSDK1.2

I used PEx to generate the code.

I modified FreeRTOSConfig.h to use configFRTOS_MEMORY_SCHEME==1

 

The event is created in main

            event_t msgInEvent;

           if (OSA_EventCreate(&msgInEvent, kEventAutoClear) != kStatus_OSA_Success) {
               PRINTF("Inside %s, OSA_EventCreate failed\n", __FUNCTION__);

            }

 

 

 

 

The wait is in task2

            if (OSA_EventWait(&msgInEvent, 0x01, 1, OSA_WAIT_FOREVER, NULL) != kStatus_OSA_Success) {

                       PRINTF("Inside %s, OSA_EventSet failed\n", __FUNCTION__);

            }

 

 

The Set is in task1

            if (OSA_EventSet(&msgInEvent, 0x01) != kStatus_OSA_Success) {

                      PRINTF("Inside %s, OSA_EventSet failed\n", __FUNCTION__);

            }

 

when I pause the CPU I get

 

rtosTest_Debug_PNE [GDB PEMicro Interface Debugging]          

            rtosTest.elf     

                        Thread #1 <main> (Suspended : Signal : SIGINT:Interrupt)

                                    WDOG_EWM_IRQHandler() at startup_MK22F51212.S:349 0x4e8        

                                    <signal handler called>() at 0xfffffffd          

                                    vPortStartFirstTask() at port.c:675 0x2852   

                                    xPortStartScheduler() at port.c:554 0x2792  

            C:\Freescale\KDS_3.0.0\eclipse\plugins\com.pemicro.debug.gdbjtag.pne_2.0.8.201504092111\win32\pegdbserver_console           

            arm-none-eabi-gdb     

 

Any help is appreciated

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
2,619件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi Joe,

You are correct...I was a bit too fast on the reply.  I thought I saw all that was to be.  Sorry.

On further inspection, please make following changes to the project Task2_task and it will work:

  /* Write your local variable definition here */

    event_flags_t setFlags; //DES added

#ifdef PEX_USE_RTOS

  while (1) {

#endif

    /* Write your code here ... */

  OSA_TimeDelay(10);

  PRINTF("inside %s Waiting for event\n", __FUNCTION__);

  if (OSA_EventWait(&msgInEvent, 0x01, 1, OSA_WAIT_FOREVER, &setFlags) != kStatus_OSA_Success) { //DES last parameter cannot be "NULL"

Terminal Output:

jab inside Task1_task

Inside Task1_task, malloc size = 0x22, addressed = 0x1fff2070

inside Task2_task Waiting for event

jab inside Task1_task sending event

jab inside Task2_task Got event!

Regards,

David

元の投稿で解決策を見る

0 件の賞賛
返信
7 返答(返信)
2,619件の閲覧回数
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Joe Birch,

Would you please send your project for a review? Thanks for your patience!


Have a great day,
Kan

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

0 件の賞賛
返信
2,619件の閲覧回数
joebirch
Contributor III

Here is the project

thanks

0 件の賞賛
返信
2,619件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi Joe,

Two things.

First you should not make RTOS calls prior to the RTOS starting up.

Second changing the config_FRTOS_MEMORY_SCHEME from 3 to 2 in the FreeRTOSConfig.h header.

Then the terminal output looks like:

Inside main

jab inside Task1_task

Inside Task1_task, malloc size = 0x22, addressd = 0x1fff1870

inside Task2_task Waiting for event

jab inside Task1_task sending event

Updated project attached.

Regards,

David

0 件の賞賛
返信
2,619件の閲覧回数
joebirch
Contributor III

David

Thanks for the quick response but the event still is not received

.

The output in your reply doesn't show it working either, there should be a " Got event!" output

Joe

0 件の賞賛
返信
2,620件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi Joe,

You are correct...I was a bit too fast on the reply.  I thought I saw all that was to be.  Sorry.

On further inspection, please make following changes to the project Task2_task and it will work:

  /* Write your local variable definition here */

    event_flags_t setFlags; //DES added

#ifdef PEX_USE_RTOS

  while (1) {

#endif

    /* Write your code here ... */

  OSA_TimeDelay(10);

  PRINTF("inside %s Waiting for event\n", __FUNCTION__);

  if (OSA_EventWait(&msgInEvent, 0x01, 1, OSA_WAIT_FOREVER, &setFlags) != kStatus_OSA_Success) { //DES last parameter cannot be "NULL"

Terminal Output:

jab inside Task1_task

Inside Task1_task, malloc size = 0x22, addressed = 0x1fff2070

inside Task2_task Waiting for event

jab inside Task1_task sending event

jab inside Task2_task Got event!

Regards,

David

0 件の賞賛
返信
2,619件の閲覧回数
joebirch
Contributor III

David

That was it. My mistake (but the API could have returned an error :smileyhappy:)

Thanks

Joe

0 件の賞賛
返信
2,619件の閲覧回数
DavidS
NXP Employee
NXP Employee

Agreed about driver returning an error.

Regards,

David

0 件の賞賛
返信