Hi,
I've been testing/using the mqxlite component in KDS with processor expert.
I've added 3 tasks to the template list, the first task is my startup task and the other two tasks implement product specific functions using some other processor expert LDD's. They are not marked auto start (TASK_ATTRIBUTES does not have MQX_AUTO_START_TASK set).
The start up task creates some events/timers/semaphores for synchronization and then the intention is to have it start the other tasks. However i can't seem to find an MQX Lite function to start tasks that were included in the task template list.
_task_create(...) looks like it is what i want but:
1) it is not defined in any include file.
2) it does not work correctly because it eventually calls _task_build_internal with stack_ptr and stack_size set to null/0. This causes that function to try and allocate them again even though processor expert already globally allocated stacks with the size that i selected in the UI.
3) calling it anyways eventually results in an unhanded interrupt and a (debug) halt.
Maybe there is a function that already exists but i could not find it.
I dont' have any experience with MQX lite and the older code warrior so i have no idea if this is specific to KDS or not....
For now, I've hacked up my own task_create_from_template function that traverses the task template list and it works just fine, code is bellow.
void task_create_from_template(uint32_t taskNumber)
{
_int_disable();
extern KERNEL_DATA_STRUCT_PTR _mqx_kernel_data;
extern TD_STRUCT_PTR _task_init_internal(
TASK_TEMPLATE_STRUCT_PTR template_ptr,
_task_id creator_task_id,
uint_32 create_parameter,
boolean dynamic,
pointer input_stack_ptr,
_mem_size input_stack_size
);
//GER_KERNEL_DATA macros is defined in some internal MQX lite header
//I'd rather not include that in this file, so the implementation was in-lined manually
KERNEL_DATA_STRUCT_PTR kernel_data = _mqx_kernel_data;
{
TD_STRUCT_PTR td_ptr;
TASK_TEMPLATE_STRUCT_PTR template_ptr;
int task_index = 0;
template_ptr = kernel_data->INIT.TASK_TEMPLATE_LIST;
while (template_ptr->TASK_TEMPLATE_INDEX) {
if (template_ptr->TASK_TEMPLATE_INDEX == taskNumber) {
td_ptr = _task_init_internal(template_ptr,
kernel_data->ACTIVE_PTR->TASK_ID,
template_ptr->CREATION_PARAMETER,
FALSE,
(pointer)mqx_task_stack_pointers[task_index],
(_mem_size)template_ptr->TASK_STACKSIZE);
_task_ready_internal(td_ptr);
_int_enable();
return;
} /* Endif */
++template_ptr;
++task_index;
} /* Endwhile */
}
_int_enable();
}
Did you try using _task_create_at() to start the non-auto tasks? I have been using this to start MQX Lite taks that did not have the AUTO_START enabled.