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.

Multiple indipendent task

Other Parts Discussed in Thread: CC3200

I'm trying to create an application with multiple tasks.
I try to explain my aim using only two task, for semplicity.

I want a first task to connect the CC3200 to my wlan network
and periodically checks if there is connection (so it has highest priority)

than there is a second task (even more than one) which collect information from sensors,
for example it collect temperature measurement.

The tasks are independent and doesn't communicate each other.

I did it this way:

in main function I have all initializations (variables, sensors, terminal)
and then I have:


osi_TaskCreate(ConnectionTask, (signed char*)"ConnectionTask", \
                                2048, NULL, \
                                2, NULL );

    
osi_TaskCreate(TemperatureTask, (signed char*)"TASK1",\
                                    1024, NULL,
                                1, NULL );
 


ConnectionTask starts a cycle every 3 minutes to check the connection
TemperatureTask starts a cycle every minute to save collected data.

Do I need a semaphore to do this?

  • Hi Maris,


    No need of semaphore, If both are independent and doesn't need any communication between them.


    Re
  • Thank you for your answer Aashish.

    I'm trying to understand my problem.

    I think that the first task enters in an infinite loop and never stops since the other task has lower priority.

    I though, wrongly, that a semaphore was needed.
  • Hi,


    Use osi_Sleep(). This is easiest way for you.

    Jan

  • I use it in my tasks

    I did this way

    void main()
    {
        BoardInit();
        PinMuxConfig();
    
        PinConfigSet(PIN_58,PIN_STRENGTH_2MA|PIN_STRENGTH_4MA,PIN_TYPE_STD_PD);
    
        InitializeAppVariables();
    
        InitTerm();
        
        GPIO_IF_LedConfigure(LED1);
        GPIO_IF_LedOff(MCU_RED_LED_GPIO);
    
        I2C_IF_Open(I2C_MASTER_MODE_FST);
    
        TMP006DrvOpen();
    
        //ReadDeviceConfiguration();
    
    
        VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);
    
        
        osi_TaskCreate(firstTask, (signed char*)"firstTask", \
                                    2048, NULL, \
                                    1, NULL );
    
    
        osi_TaskCreate(connectionTask, (signed char*)"connectionTask",\
            							1024, NULL,
    									2, NULL );
    
        osi_TaskCreate(mdnsTask, (signed char*)"mdnsTask",\
               							1024, NULL,
       									1, NULL );
    
        osi_start();
    
        while (1)
        {
    
        }
    
    }

    and my tasks are:

    static void firstTask(void *pvParameters)
    {
    
       float fCurrentTemp;
    
       for (;;)
       {
    	   TMP006DrvGetTemp(&fCurrentTemp);
    	   UART_PRINT("il valore è %f \n\r", fCurrentTemp);
    	   osi_Sleep(10000);
       }
    }
    
    //****************************************************************************
    
    static void connectionTask(void *pvParameters)
    {
       ReadDeviceConfiguration();
       ConnectToNetwork();
    }
    
    //****************************************************************************
    
    static void mdnsTask(void *pvParameters)
    {
        int sleep = FIRST_INTERVAL;
        long mdnsRetVal;
    
        for (;;)
    	{
    
    	   do
    	   {
    		   mdnsRetVal = mDNS_advertise();
    		   osi_Sleep(sleep);
    		   sleep = ADVERTISING_INTERVAL;
    	   } while(mdnsRetVal < 0); // i use this cycle because first mdns registration fails
    
    	}
    }

  • If I remove ConnectToNetwork and mDNS_advertise and I substitute them
    with a simple task that does something not related to nwp it works.

    What can be the problem with nwp operations?

    EDIT: I found that the problem is the mDNS_advertise function; it always fails the first advertising

  • Hi Maris,


    Before starting mDNS, device need to acquire the IP. Please make sure before calling mDNS_advertise() device is connected to AP and acquired the IP. Please refer mDNS example code fron SDK.


    Regards,
    Aashish
  • Hi Aashish,

    I'm able to do mDNS registration, but only one time.

    I would like to repeat it periodically, but I'm not able to do this.

    The code seems to be ok.
  • I don't know why but after formatting and reinstalling service pack it work without any change in my code.

  • Hi Maris,


    As issue is resolve we are closing this thread, for follow up queries please open a new thread and add a link to this one for reference.


    Regards,
    Aashish