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 : SlNonOsSemGet function infinite loop?

Other Parts Discussed in Thread: CC3100

I'm porting cc3100 for stm32f4 and don't understand the functionnement, in  _SlDrvSyncObjWaitForever call during sl_Start function, of :

_SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout)
{
#ifdef _SlSyncWaitLoopCallback
    _SlNonOsTime_t timeOutRequest = Timeout;
#endif
    while (Timeout>0)
    {
        if (WaitValue == *pSyncObj)
        {
            *pSyncObj = SetValue;
            break;
        }
        if (Timeout != NONOS_WAIT_FOREVER)
        {        
            Timeout--;
        }
        _SlNonOsMainLoopTask();
#ifdef _SlSyncWaitLoopCallback
        if( (__NON_OS_SYNC_OBJ_SIGNAL_VALUE == WaitValue) && (timeOutRequest != NONOS_NO_WAIT) )
        {
            if (WaitValue == *pSyncObj)
            {
                *pSyncObj = SetValue;
                break;
            }
            _SlSyncWaitLoopCallback();
        }
#endif
    }

    if (0 == Timeout)
    {
        return NONOS_RET_ERR;
    }
    else
    {
        return NONOS_RET_OK;
    }
}

Timeout and NONOS_WAIT_FOREVER is define by 255 so the function loop infinitly.

So my question is why? =)

  • i read that it's a problem with my interrup?
  • Hi Dupont,

    sl_Start() will wait forever for the init sequence to complete, unless a callback is specified in the parameter list.

    -Aaron

  • Hi Aaron,

    Thanks for help, you mean sl_Start() wait for interrupt IRQ goes HIGH? Because it already go high, when i check it with a scope, but the code always loop in SlNonOsSemGet function. You think it's a bad connection of my irq receive on my STM32F4?

    Best Regard
  • I don't see or understand, in function " _SlNonOsSemGet ", where *psyncObj is update :

    if (WaitValue == *pSyncObj)
    {
    *pSyncObj = SetValue;
    break;
    }

    Because now i always have a " NONOS_RET_ERR "

    if (0 == Timeout)
    {
    return NONOS_RET_ERR;
    }
    else
    {
    return NONOS_RET_OK;
    }

    And if the return value is NONOS_RET_ERR, the code go in infinite loop. So that's my problem.

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


    _SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout)
    {
    /*#ifdef _SlSyncWaitLoopCallback
    _SlNonOsTime_t timeOutRequest = Timeout;
    #endif*/
    while (Timeout>0)
    {
    if (WaitValue == *pSyncObj)
    {
    *pSyncObj = SetValue;
    break;
    }
    if (Timeout != 256)
    {
    Timeout--;
    }
    _SlNonOsMainLoopTask();
    /*#ifdef _SlSyncWaitLoopCallback
    if( (__NON_OS_SYNC_OBJ_SIGNAL_VALUE == WaitValue) && (timeOutRequest != NONOS_NO_WAIT) )
    {
    if (WaitValue == *pSyncObj)
    {
    *pSyncObj = SetValue;
    break;
    }
    _SlSyncWaitLoopCallback();
    }
    #endif*/
    }

    if (0 == Timeout)
    {
    return NONOS_RET_ERR;
    }
    else
    {
    return NONOS_RET_OK;
    }
    }

  • HI Dupont,

    Make sure you register the interrupt handler for the IRQ in user.h - sl_IfRegIntHdlr()

    -Aaron
  • Hi Aaron,

    in my user.h file, i define :

    #define sl_IfRegIntHdlr(InterruptHdl , pValue)    EXTI15_10_IRQHandler(InterruptHdl , pValue)


    and in my porting file, i define :


    void EXTI15_10_IRQHandler(P_EVENT_HANDLER InterruptHdl , void* pValue){
        int etat,i;
        if (EXTI_GetITStatus(EXTI_Line12) != RESET){

            pIrqEvtHdlr = InterruptHdl;

            EXTI_ClearFlag(EXTI_Line12);
        }

    }

     

    Because in the SDK, the function do :

    int registerInterruptHandler(P_EVENT_HANDLER InterruptHdl , void* pValue)
    {
        pIraEventHandler = InterruptHdl;

        return 0;
    }

     

    I'm wrong?

    Thanks

  • Hi Dupont,
    It should be
    #define sl_IfRegIntHdlr(InterruptHdl , pValue) registerInterruptHandler(InterruptHdl , pValue)

    Also, pIraEventHandler should be called by the interrupt routine

    -Aaron
  • Hi Aaron,

    So i change the declaration by :

    in user.h :

    #define sl_IfRegIntHdlr(InterruptHdl , pValue)   registerInterruptHandler(InterruptHdl , pValue)

    and in my porting file :

    int registerInterruptHandler(P_EVENT_HANDLER InterruptHdl , void* pValue){

    pIraEventHandler = InterruptHdl;
    return 0;
    }

    But Now, my code stuck as soon as the irq signal go high.

  • What does it look like now?
  • I try to debug with breakpoint. I can use breakpoint until the IRQ goes High. When the IRQ goes High, my breakpoint are not reach, the execution code look like it loop on function or it stucks.
    I'm sure it's an IRQ problem, because i can use as much breakpoint as i want before IRQ, but when the IRQ goes High, no breakpoint are reach.
  • What does your interrupt handler look like?

    -Aaron

  • Hi,

    Oh it's ok, i made a huge error, i found an old interrupt handler connect on the same pin.. that's why it could not works. Can I ask you a last question until i found a new one? =) Did the Master send data during sl_Start function to cc3100 over SPI communication?

    Thanks

    Dupont
  • Yes, sending data to the CC3100 is part of the initialization

    -Aaron
  • ok , but i use cc3100 sdk and in function sl_Start i don't found where sending data function is call for sending initialization code to cc3100 ( which much look like 0x65, 0x87, 0x78, 0x56, if i understand ). So when my function sl_Start is executed, i see nothing with my scope on MOSI and CLK communication.

    ps: My SPI communcation works, I already check it.

    Dupont
  • Solve,
    i work under eclipse envirronement and eclipse don't understand Interweaving of function call like :

    sl_IfRegIntHdlr(_SlDrvRxIrqHandler, NULL);

    So i change it by :

    _SlDrvRxIrqHandler(0);
    sl_IfRegIntHdlr( NULL , NULL);

    And know, i see the four initialization data send over SPI communication.

    - Dupont
  • HI Dupont,

    I'm not sure how this change would accomplish what the function intended. How would control get passed to the Simplelink driver in this case?

    -Aaron
  • Hi,

    That's true, it could not works for a stable usage. so i redefine :

    sl_IfRegIntHdlr(_SlDrvRxIrqHandler, NULL);

    By default i placed a wait time between initialization SPI and first function , and i should not. Because with this the IRQ came before sl_IfRegIntHdlr is define.
    Now it works. I observe, with scope, the 4 initialization data ( STM32F4 -> CC3100 ) and validation code ( CC3100 -> STM32F4 )

    STM32F4 -> CC3100 ( Sending ) : 0x65 ; 0x87 ; 0x78 ; 0x56
    CC3100 -> STM32F4 ( Receiving ) : 0x00 ; 0x00 ; 0x00 ; 0x00
    CC3100 -> STM32F4 ( Receiving ) : 0xBC ; 0xDC ; 0xCD ; 0xAB
    CC3100 -> STM32F4 ( Receiving ) : 0x08 ; 0x00 ; 0x08 ; 0x00
    CC3100 -> STM32F4 ( Receiving ) : 0x00 ; 0x00 ; 0x00 ; 0x00
    CC3100 -> STM32F4 ( Receiving ) : 0x33 ; 0x33 ; 0x33 ; 0x33

    Thanks Aaron, I like to create my mistakes myself . ^^

    - Dupont
  • But The IRQ don't go down... WHy?