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
解決済! 解決策の投稿を見る。
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
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!
-----------------------------------------------------------------------------------------------------------------------
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
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
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
David
That was it. My mistake (but the API could have returned an error :smileyhappy:)
Thanks
Joe
Agreed about driver returning an error.
Regards,
David