This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540 : osal_mem_allocate

Hi,

       Can someone please help me with osal_msg_allocate,

I am trying to send the data from HAL_ISR_FUNCTION (which I written in the main app) which is in the Keyfobdemo.c

I have read the documentation what i understood was allocate memory and use the buffer pointer to send the data or the Event_Msg to send different task using osal_msg_send

Below here is my code snippet, I am trying to do this

unit16 *timeStamp_1_ptr, timeStamp_1; 

timeStamp_1_ptr = &timeStamp_1;

timeStamp_1_ptr = (timeStamp_1 *)osal_msg_allocate(sizeof(timeStamp_1));

timeStamp_1 = osal_GetSystemTime();

am i doing it right ? If not please guide me through

The questions which I have are :

1. What shoudl be the pointer to the buffer (osal_msg_allocate) declared as?

2. Whatever the data I get how do i put it to the buffer ?


The Error which I am getting is :

Error[Pe029]: expected an expression         C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\Stridalyzer\Source\keyfobdemo.c 1133
Error[Pe065]: expected a ";"                            C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\Stridalyzer\Source\keyfobdemo.c 1133
Error[Pe029]: expected an expression         C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\Stridalyzer\Source\keyfobdemo.c 1137
Error[Pe065]: expected a ";"                             C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\Stridalyzer\Source\keyfobdemo.c 1137

Please guide me through ASAP.


Regards,

Rakesh

  • You should revise "timeStamp_1_ptr = (timeStamp_1 *)osal_msg_allocate(sizeof(timeStamp_1));" to "timeStamp_1_ptr = (uint16 *)osal_msg_allocate(sizeof(timeStamp_1));"

  • Also there is no meaning of "timeStamp_1_ptr = &timeStamp_1;"  this statement. As in the next line the pointer is going to be overwrite by the new pointer returned by "osal_msg_allocate" function.

    And if you want keep that then there is not need to allocate new memory at all.

  • Ok, So can please clarify me, What I am trying to here is

    I am trying to get the timeStamp value by using osal_GetSystemClock() function call, so whatever value I get, i need to send it from HAL_ISR_FUNCTION to keyfobdemo app, i.e is the main function.

    So I am using the osal_msg_send, since I am using it I need to allcoate memory before doing it right ?

    To send the data , first i am allocating memory and then what to store the data in the memory

    Here,

    timeStamp_1 = osal_GetSystemClock(); ----------------------> is the data

    So, How do i store it store it in the memory if I am not point the buffer pointer to data ?

    If you can clarify me, how do I store the timeStamp_1 data value in the memory and use osal_msg_send

    Regards,

    Rakesh

  • uint32 *timeStamp_1_ptr = NULL; // osal_GetSystemClock() returns uint32

    timeStamp_1_ptr = (uint32 *) osal_msg_allocate(sizeof(uint32));

    *timeStamp_1_ptr = osal_GetSystemTime();

    osal_msg_send(__destination_task__, timeStamp_1_ptr);

    // you need to free the memory allocated here in the destination task.

    I think this should work.

    Thanks,

    Dhaval

  • Why don't you use timeStamp_1 as global variable? You can declare "uint32 timeStamp_1;" in hal_key.c and extern it at the c file where you want to use it. 

  • I have done that too.

    I am writing my ISR Fuction in the main file itself and setting up the event.

    Now its working the way I want...

    Thank you

    - Rakesh