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.

how to run two Thread for two different application in zstackHA1.20 for cc2538

Other Parts Discussed in Thread: CC2538, CC2591, Z-STACK

Hello All,

I am using zstack HA 1.20 and cc2538 for my project.

i know how zigbee is working and how it is monitoring for event in the task arr...

but i want to implement something like this - 

1) i hav my another application code with main() and in that under while(1) loop i am monitoring my sensors data and processing it.... this application is for cc2538 only..

2) in this application i am creating some flag and as per the sensors data i am modifying this flag.

3) now i want zigbee event loop to come and check this flag whenever there is a change in my flag data....for ex..if in my flag fire sensor bit is getting high then zigbee should start executing ISR related to it and once it finishes the ISR it should return the control to my main code.........zigbee will not check for any HAL or GPIO or UART kind of interrupt all will be handled by main application...i want zigbee just for sending data OTA to another zigbee device.... but my application code and zigbee stack should be on single cc2538 chip.....

4) all i want is 2 thread one for zigbee application and other for my main application......one will execute my main code and if any flag bit is set by my application then another 2nd thread should take control and execute ISR and send data OTA and then reurn control to my main thread.....

5) i dont want to register my main code in task array of zigbee like generally we are doing.....

6) zigbee is like a ISR for me whenever my flag bit is sent it will take my flag data and sent OTA and again return control to my main code....

anyone plz help me and guide me how can i do this or how i can implement this....

Thanks & Regards,

Maneesh SIngh

  • Maneesh,

    There is no OS running on CC2538 when you run HA1.2, hence no threads. OSAL schedules events for ALL ZStack components/tasks . You will need to schedule an event for your app task  and perform necessary actions ( like reading sensors etc) .  Consult OSAL APIs ex: osal_start_reload_timer/osal_start_timerEx to raise events after certain time duration. In the event handler fn  you may add the action/s you intend to perform.

    Saurabh

  • Hello Saurabh Narang,

    thanks for replying...

    whatever ur saying that is right....

    i know that how zigbee is working....first in zmain it will initialize all the H/W and then using osal_start_system fn start the zigbee working where it will in round robin fashion checks for all the HAL, MAC, NWK and users event and if any event is coming it will inform the application level and perform event handler or ISR for that event..... it has one task array in that we are registering our events and zigbee continuously scans this task array for any events changes....... am i right? but what i want to do is that ->

    i hav my own set of code with hal & driverlib etc... now in this setup i am interfacing few sensors to cc2538 and getting its value and i hav one event flag in that based on the sensor data i am setting particular bits now i want to port zstack HA 1.20 on this cc2538 and wat i want is that ->

    1) zstack periodically check my event flag and send status to ZC OTA                                                                      2) if any bit in my event flag changes then zigbee should come and check it and send it OTA to ZC                            3) if ZC sends and cmd or packet zigbee should take control receive it process it and perform event associated with that cmd and again go back to sleep mode and give control to my main code.

    zigbee is kind of ISR for me....my code should hav all the control over program execution...i'll run a timer so if that timer expire or if any sensor bit in my event flag is getting change then only zigbee code should start running and read my event flag and send it OTA and again stops and send control to my main code....

    u can think there are two application is running parallely one is my main code other is zigbee code my main code will do changes in event flag and zigbee code will monitor /scan it and send to ZC...

    Hope i explained my problem..

    any help will be appreciated... plz reply..

    Thanks & Regards,

    Maneesh

  • Hello Saurabh Narang,

    i am using cc2538 and zstack1.2.0 HA but now in my custom board we interfaced cc2538 with cc2592..

    1) will you plz tell me how i can use it means where i hav to define HAL_PA_LNA in the IAR->option->c/c++compiler option-> defined symbol  or in my <sampleapp.c> fle and how to define it,     is this ok ->#define HAL_PA_LNA or how?

    2) any other setting i hav to do or by defining only this single macro i am able to use my cc2592 ? if yes then what and where ?

    3) i checked in Z-Stack Home 1.2.0 -> mac_radio_defs.c file there is nothing for cc2592 they are using cc2591 or cc2590only....

    4) and in HAL_API.c pdf it is written there that i need to define these 2 macro -> HAL_PA_LNA_RX_LGM()   and HAL_PA_LNA_RX_HGM()...... will you plz tell me where and in which file i hav to define this macro ? and is any other code also i hav to write ?

     

    plz reply sir...

    Thanks & Regards,

    Maneesh singh

  • hello all....

    finally i solved this HA_PA_LNA problem.......

    now i am able to transmit and receive more than 35 - 50 feet.....

  • Hello TI and all,

     is there anyone who can help me in my previous post...that how my main code and zstack can co-exist together....

    anyone plz help me to solve this issue....

    any help will be appreciated...

    plz reply anyone..

    Thanks & Regards,

    Maneesh singh

  • Hi Maneesh,

    There is no thread mechanism in Z-Stack. You should following osal API to implement application on CC253x. According to my experiences, you don't have to use any complex OS function implement application.