Problem with OS task events using freeRTOS.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Problem with OS task events using freeRTOS.

跳至解决方案
3,725 次查看
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,618 次查看
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,618 次查看
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,618 次查看
joebirch
Contributor III

Here is the project

thanks

0 项奖励
回复
2,618 次查看
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,618 次查看
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,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 项奖励
回复
2,618 次查看
joebirch
Contributor III

David

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

Thanks

Joe

0 项奖励
回复
2,618 次查看
DavidS
NXP Employee
NXP Employee

Agreed about driver returning an error.

Regards,

David

0 项奖励
回复