ThreadX task start

I want to initialize several bits of hardware prior to my tasks running and control the order of tasks that are started.  Other posts recommend putting initialization code in tx_application_define_user, fine.  It look like I should change "Auto start" to disabled so I can control start order but where should I put the code that actually starts my tasks.

 

Thanks

  • Hi Mike,

    You should have only one thread with "Auto start" and in it you can do your hardware initialization. When ready you can resume other threads using their thread handle.

    Another way is if all thread are auto start, you can get the thread to suspend itself and only allow the thread doing the hardware initialization to proceed. After ready, you can resume the other threads.
  • I am also trying to initialize hardware as soon as possible, is the correct place tx_application_define_user or should I go somewhere else?  My criteria are:

    1. I do want to run as early as possible,
    2. I do not want to interfere with auto generated code.  That is I do not want to hand edit some start up code that will get overwritten by the auto generate function nor that will cause auto generate to not proceed.

    Thanks again 

  • tx_applicaiton_define_user is a weak function. You can certainly define yours and replace it.
    Putting your hardware init code would make it run earlier than placing it in the first running thread.

    If the hardware init code requires a hal driver, or if immediately after init, you need to handle events from the hardware, then is better to init hardware in first running thread.