Other Parts Discussed in Thread: SYSBIOS
Hi,
I hit on a problem on my project with TDA4VMXEVM.
My project uses Ti RTOS and which runs on MCU2_0 of TDA4VMXEVM. (First R5 at Main domain).
I need to synchronize some RTOS tasks with own semaphores.
At first step, I created these semaphores dynamically with OSAL abstraction layer "extern SemaphoreP_Handle SemaphoreP_create(uint32_t count, const SemaphoreP_Params *semParams);" and all following usage of that SemaphoreP_Handle was implemented using the OSAL functions (pend/post/delete).
That state worked so far.
Now I thought it's a good idea to instantiate theses semaphores with RTOS app.cfg in a static way:
var semaphore0Params = new Semaphore.Params(); semaphore0Params.instance.name = "SemST25RISR"; semaphore0Params.mode = Semaphore.Mode_COUNTING_PRIORITY; Program.global.SemST25RISR = Semaphore.create(5, semaphore0Params);
Now some problems arised: Using this static instance "SemST25RISR" with the OSAL-functions won't work, since the type of that static instance seems to be different to the type of OSAL function (thats what I think at least).
This is the definition of SemaphoreP_tiRtos structure OSAL function creates:
/*!
* @brief Semaphore structure
*/
typedef struct SemaphoreP_tiRtos_s {
Bool used;
Semaphore_Struct sem;
} SemaphoreP_tiRtos;
"sem" (in the end) has the same structure of ti_sysbios_knl_Semaphore_Object__ which you can see below.
This is the definition of Semaphore structure which creates xdc/Ti RTOS statically (I don't know what really creates the c-code from app.cfg)
/* @@@ ti_sysbios_knl_Semaphore_Object__ */
typedef struct ti_sysbios_knl_Semaphore_Object__ {
ti_sysbios_knl_Event_Handle event;
xdc_UInt eventId;
ti_sysbios_knl_Semaphore_Mode mode;
volatile xdc_UInt16 count;
ti_sysbios_knl_Queue_Object__ Object_field_pendQ;
} ti_sysbios_knl_Semaphore_Object__;
When I use now the static created semaphore object (ti_sysbios_knl_Semaphore_Object__) with OSAL pend function (SemaphoreP_pend), all the read values are shifted one Byte to the higher memory address, because of the "Bool used;" from type SemaphoreP_tiRtos_s. So in the end, the value "count" corrensponds with the first 16 bit of "Object_field_pendQ" which is the memory address of that semaphore object.
So my question is: I think writing code against OSAL layer is commonly a good idea, to get increased portability. Also I think creating Ti RTOS objects in a static way is a good idea to get better control of memory consumption/ usage estimation.
How can I combine these two approaches, without running in such nasty things?
Best regards,
Thomas