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.

CC3100: How can I initialize cc3100 using interrupts?

Part Number: CC3100
Other Parts Discussed in Thread: MSP430F5529

Hello everyone!

This is what I would like to achive:

After calling sl_Start, i dont want to wait and until it finishes initializing itself, because I would like to collect data from my sensors.

Is it possible to  get an interrupt that tells me, that the cc3100 is finished with initializing and I can start working with it?

If so, could someone explain it to me?

Best Regards,

Bálint

  • Hi Bálint,

    You shroud try to use sl_Start() in callback mode. Please see www.ti.com/.../swru368 at chapter 3.1 ("Asynchronous").

    Jan
  • Dear Hnz,

    Thank you for replying to my post.

    The link you posted was very usefull ( i somehow skipped through that chapter). I tried to implement it in a simple test code, but i wasnt very successful. Could you please tell me where i went wrong? I included my test code below. I am using the msp430f5529 launchpad with the cc3100.

    void InitCallBack(_u32  Status){
        CLI_Write("init done");
    }
    
    int main(int argc, char** argv){
        WDTCTL = WDTPW + WDTHOLD;
        initClk();
    
        CLI_Configure();    // tera term
        void (*fptr) (_u32)=InitCallBack;
        CLI_Write("WLAN AP MODE\n\r");
    
        sl_Start(NULL, NULL, fptr);// init CC3100
    
    
    
        sl_WlanSetMode(ROLE_AP);            // CC3100 to AP mode
        while(1){};
    }
    

  • Hi,

    I think you should have some "blocking" code between sl_Start() and sl_WlanSetMode(). Because sl_Start() in asynchronous mode should return immediately. That means in your case you call sl_WlanSetMode() in moment when CC3100 is not started yet.

    Also is a good practice to read return codes from sl_ API to be sure that API was executes successfully.

    Jan
  • Dear Jan,

    Thank you for replying.

    If I dont use the callback mode and use this code:

        sl_Start(NULL, NULL, NULL);         // init CC3100
        sl_WlanSetMode(ROLE_AP);            // CC3100 to AP mode

    or if i use the callback mode like this:

    void InitCallBack(_u32  Status){
        CLI_Write("init done");
        sl_WlanSetMode(ROLE_AP);            // CC3100 to AP mode
    }
    
    int main(int argc, char** argv){
        WDTCTL = WDTPW + WDTHOLD;
        initClk();
    
        CLI_Configure();    // tera term
        void (*fptr) (_u32)=InitCallBack;
        CLI_Write("WLAN AP MODE\n\r");
    
        sl_Start(NULL, NULL, fptr);// init CC3100
    
        while(1){};
    }

    than i get the same result.

    The sl_Start function's return value is SL_RET_CODE_OK, which is the expected value.

    Tbh, i dont really understand the initialization of the cc3100.

  • Hi,

    In asynchronous handler you cannot call sl_ API at CC3100 devices. I expect this will be same with init-callback as well.

    Your code should look like:

    int init_done = 0;
    
    
    void InitCallBack(_u32  Status){
        CLI_Write("init done");
        init_done = 1;   
    }
    
    int main(int argc, char** argv){
        WDTCTL = WDTPW + WDTHOLD;
        initClk();
    
        CLI_Configure();
        void (*fptr) (_u32)=InitCallBack;
        CLI_Write("WLAN AP MODE\n\r");
    
        sl_Start(NULL, NULL, fptr);
    
        while(init_done == 0) {

    // your code till is init of CC3100 done...

    } sl_WlanSetMode(ROLE_AP); while(1){}; }

    Jan

  • Dear Jan,

    I copied your code, but the InitCallBack function is not called, and i get stuck in the while.

    This is the code i run:

    int init_done = 0;
    
    
    void InitCallBack(_u32  Status){
        CLI_Write("init done");
        init_done = 1;
    }
    
    int main(int argc, char** argv){
        WDTCTL = WDTPW + WDTHOLD;
        initClk();
    
        CLI_Configure();
        void (*fptr) (_u32)=InitCallBack;
        CLI_Write("WLAN AP MODE\n\r");
    
        sl_Start(NULL, NULL, fptr);
    
        while(init_done == 0) {  CLI_Write("-"); }    // your code till is init of CC3100 done...
    
    
    
        sl_WlanSetMode(ROLE_AP);
        
    
        while(1){};
    }
    

  • Hi,

    OK, try add _SlNonOsMainLoopTask(); into while() loop. This function serve asynchronous handlers in case of non-RTOS code is used.

    Jan
  • Thank you very much for your help, this resolved my issue.