I have two tasks running one for the GUI and one for a global counter. The GUI task is called when ever there is a button input. The global counter task called task_timer_handler is called from a function call in the GUI task if a button was pressed in a specific state. The event is getting set and the global counter task is getting called, but when I use the os_evt_get() function I'm always getting 0x0000 back. I don't understand what I'm doing wrong.
__task void task_agui_handler(void) { OS_RESULT result; initialize_user_io(); // initializes the encoder interrupt while(1) { result = os_evt_wait_and(0x1,0xFFFF); // result gets 0x02 value of waiting indefinitly for any 0x000F events to occur (any first 4 bits 1) switch(result) // result is OS_R_EVT = 0x02 { case OS_R_EVT: // if result is 0x02, event occurred\ agui_handler(agui); break; case OS_R_TMO: // code should never get here (time out occurred during wait for event) break; default: // code should never get here break; } os_tsk_pass(); // allows tasks of same priority level to run coop. } } __task void task_timer_handler(void) { OS_RESULT result; U16 event_flags; int rotations; while(1) { result = os_evt_wait_or(0x0003,0xFFFF); switch(result) // result is OS_R_EVT = 0x02 { case OS_R_EVT: // if result is 0x02, event occurred\ event_flags = os_evt_get(); if((event_flags & 0x0002) == 0x0002) { fast_count = 1; rotations = 0; } break; case OS_R_TMO: // code should never get here (time out occurred during wait for event) break; default: // code should never get here break; } os_tsk_pass(); // allows tasks of same priority level to run coop. } }
This is the part of the function that calls the timer_handler_task
else if(cur_obj->state == ACTION_STATE_CHANGE) { if((HMI_inputs >> 7) == 1) // count up { state->x = 0; state->y = 0; state->buttons = BUTTON_INC; state->relative = TRUE; os_evt_set(0x0002,task_ids[TIMER_TASK]); } else if((HMI_inputs >> 6) == 1) // count down { state->x = 0; state->y = 0; state->buttons = BUTTON_DEC; state->relative = TRUE; os_evt_set(0x0002,task_ids[TIMER_TASK]); } else if((HMI_inputs >> 5) == 1) // encoder button { state->x = 0; //cur_obj.x; state->y = 0; //cur_obj.y; state->buttons = BUTTON_ENCODER; state->relative = TRUE; } return TRUE; }
I guess I was stack overflowing because doubling the stack seems to have solved this issue.