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.

DON'T EXIT DE LOOP

Other Parts Discussed in Thread: MSP430FR5739

8863.BUCLE INFINITO.doc

I'm Juan Pedro, working over msp430fr5739 6 cc3000,  and the iar 6.20 compiling. 

HELLO, I HOPE hit FORUM WITH MY QUESTION,
I do not leave LOOP TO EXIT AND CONDITION IS FULFILLED.

DOES ANYONE KNOW WHAT HAPPENS?

Sure it's silly but I do not see.

Thankou for your help.

jp

  • Hi Juan,
    Can you specify which condition is breaking the loop?
    If you post the code for the faulty function we will have better scope on it.
    Regards,
    Boyko
  • Hi Boyko

    The loop is into the standar funcion:, attached at the end of mensage and the questions is.

    if (tSLInformation.usEventOrDataReceived != 0), in this case is =0, but go into for ever, see the aut tab whit  location memory 0x1c3E.

    WHy not leave?


    //*****************************************************************************
    //
    //! hci_event_handler
    //!
    //! @param pRetParams incoming data buffer
    //! @param from from information (in case of data received)
    //! @param fromlen from information length (in case of data received)
    //!
    //! @return none
    //!
    //! @brief Parse the incoming events packets and issues corresponding
    //! event handler from global array of handlers pointers
    //
    //*****************************************************************************


    UINT8 * hci_event_handler(void *pRetParams, UINT8 *from, UINT8 *fromlen)
    {
    UINT8 *pucReceivedData, ucArgsize;
    UINT16 usLength;
    UINT8 *pucReceivedParams;
    UINT16 usReceivedEventOpcode = 0;
    UINT32 retValue32;
    UINT8 * RecvParams;
    UINT8 *RetParams;


    while (1)
    {
    if (tSLInformation.usEventOrDataReceived != 0)
    {
    pucReceivedData = (tSLInformation.pucReceivedData);

    if (*pucReceivedData == HCI_TYPE_EVNT)
    {
    // Event Received
    STREAM_TO_UINT16((CHAR *)pucReceivedData, HCI_EVENT_OPCODE_OFFSET,
    usReceivedEventOpcode);
    pucReceivedParams = pucReceivedData + HCI_EVENT_HEADER_SIZE;
    RecvParams = pucReceivedParams;
    RetParams = pRetParams;

    // In case unsolicited event received - here the handling finished
    if (hci_unsol_event_handler((CHAR *)pucReceivedData) == 0)
    {
    STREAM_TO_UINT8(pucReceivedData, HCI_DATA_LENGTH_OFFSET, usLength);

    switch(usReceivedEventOpcode)
    {
    case HCI_CMND_READ_BUFFER_SIZE:
    {
    STREAM_TO_UINT8((CHAR *)pucReceivedParams, 0,
    tSLInformation.usNumberOfFreeBuffers);
    STREAM_TO_UINT16((CHAR *)pucReceivedParams, 1,
    tSLInformation.usSlBufferLength);
    }
    break;

    case HCI_CMND_WLAN_CONFIGURE_PATCH:
    case HCI_NETAPP_DHCP:
    case HCI_NETAPP_PING_SEND:
    case HCI_NETAPP_PING_STOP:
    case HCI_NETAPP_ARP_FLUSH:
    case HCI_NETAPP_SET_DEBUG_LEVEL:
    case HCI_NETAPP_SET_TIMERS:
    case HCI_EVNT_NVMEM_READ:
    case HCI_EVNT_NVMEM_CREATE_ENTRY:
    case HCI_CMND_NVMEM_WRITE_PATCH:
    case HCI_NETAPP_PING_REPORT:
    case HCI_EVNT_MDNS_ADVERTISE:

    STREAM_TO_UINT8(pucReceivedData, HCI_EVENT_STATUS_OFFSET
    ,*(UINT8 *)pRetParams);
    break;

    case HCI_CMND_SETSOCKOPT:
    case HCI_CMND_WLAN_CONNECT:
    case HCI_CMND_WLAN_IOCTL_STATUSGET:
    case HCI_EVNT_WLAN_IOCTL_ADD_PROFILE:
    case HCI_CMND_WLAN_IOCTL_DEL_PROFILE:
    case HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY:
    case HCI_CMND_WLAN_IOCTL_SET_SCANPARAM:
    case HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START:
    case HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP:
    case HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX:
    case HCI_CMND_EVENT_MASK:
    case HCI_EVNT_WLAN_DISCONNECT:
    case HCI_EVNT_SOCKET:
    case HCI_EVNT_BIND:
    case HCI_CMND_LISTEN:
    case HCI_EVNT_CLOSE_SOCKET:
    case HCI_EVNT_CONNECT:
    case HCI_EVNT_NVMEM_WRITE:

    STREAM_TO_UINT32((CHAR *)pucReceivedParams,0
    ,*(UINT32 *)pRetParams);
    break;

    case HCI_EVNT_READ_SP_VERSION:

    STREAM_TO_UINT8(pucReceivedData, HCI_EVENT_STATUS_OFFSET
    ,*(UINT8 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 1;
    STREAM_TO_UINT32((CHAR *)pucReceivedParams, 0, retValue32);
    UINT32_TO_STREAM((UINT8 *)pRetParams, retValue32);
    break;

    case HCI_EVNT_BSD_GETHOSTBYNAME:

    STREAM_TO_UINT32((CHAR *)pucReceivedParams
    ,GET_HOST_BY_NAME_RETVAL_OFFSET,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;
    STREAM_TO_UINT32((CHAR *)pucReceivedParams
    ,GET_HOST_BY_NAME_ADDR_OFFSET,*(UINT32 *)pRetParams);
    break;

    case HCI_EVNT_GETMSSVALUE:

    STREAM_TO_UINT16((CHAR *)pucReceivedParams
    ,GET_MSS_VAL_RETVAL_OFFSET,*(UINT16 *)pRetParams);

    break;

    case HCI_EVNT_ACCEPT:
    {
    STREAM_TO_UINT32((CHAR *)pucReceivedParams,ACCEPT_SD_OFFSET
    ,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;
    STREAM_TO_UINT32((CHAR *)pucReceivedParams
    ,ACCEPT_RETURN_STATUS_OFFSET,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;

    //This argument returns in network order
    memcpy((UINT8 *)pRetParams,
    pucReceivedParams + ACCEPT_ADDRESS__OFFSET, sizeof(sockaddr));
    break;
    }

    case HCI_EVNT_RECV:
    case HCI_EVNT_RECVFROM:
    {
    STREAM_TO_UINT32((CHAR *)pucReceivedParams,SL_RECEIVE_SD_OFFSET ,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;
    STREAM_TO_UINT32((CHAR *)pucReceivedParams,SL_RECEIVE_NUM_BYTES_OFFSET,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;
    STREAM_TO_UINT32((CHAR *)pucReceivedParams,SL_RECEIVE__FLAGS__OFFSET,*(UINT32 *)pRetParams);

    if(((tBsdReadReturnParams *)pRetParams)->iNumberOfBytes == ERROR_SOCKET_INACTIVE)
    {
    set_socket_active_status(((tBsdReadReturnParams *)pRetParams)->iSocketDescriptor,SOCKET_STATUS_INACTIVE);
    }
    break;
    }

    case HCI_EVNT_SEND:
    case HCI_EVNT_SENDTO:
    {
    STREAM_TO_UINT32((CHAR *)pucReceivedParams,SL_RECEIVE_SD_OFFSET ,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;
    STREAM_TO_UINT32((CHAR *)pucReceivedParams,SL_RECEIVE_NUM_BYTES_OFFSET,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;

    break;
    }

    case HCI_EVNT_SELECT:
    {
    STREAM_TO_UINT32((CHAR *)pucReceivedParams,SELECT_STATUS_OFFSET,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;
    STREAM_TO_UINT32((CHAR *)pucReceivedParams,SELECT_READFD_OFFSET,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;
    STREAM_TO_UINT32((CHAR *)pucReceivedParams,SELECT_WRITEFD_OFFSET,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;
    STREAM_TO_UINT32((CHAR *)pucReceivedParams,SELECT_EXFD_OFFSET,*(UINT32 *)pRetParams);
    break;
    }

    case HCI_CMND_GETSOCKOPT:

    STREAM_TO_UINT8(pucReceivedData, HCI_EVENT_STATUS_OFFSET,((tBsdGetSockOptReturnParams *)pRetParams)->iStatus);
    //This argument returns in network order
    memcpy((UINT8 *)pRetParams, pucReceivedParams, 4);
    break;

    case HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS:

    STREAM_TO_UINT32((CHAR *)pucReceivedParams,GET_SCAN_RESULTS_TABlE_COUNT_OFFSET,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;
    STREAM_TO_UINT32((CHAR *)pucReceivedParams,GET_SCAN_RESULTS_SCANRESULT_STATUS_OFFSET,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 4;
    STREAM_TO_UINT16((CHAR *)pucReceivedParams,GET_SCAN_RESULTS_ISVALID_TO_SSIDLEN_OFFSET,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 2;
    STREAM_TO_UINT16((CHAR *)pucReceivedParams,GET_SCAN_RESULTS_FRAME_TIME_OFFSET,*(UINT32 *)pRetParams);
    pRetParams = ((CHAR *)pRetParams) + 2;
    memcpy((UINT8 *)pRetParams, (CHAR *)(pucReceivedParams + GET_SCAN_RESULTS_FRAME_TIME_OFFSET + 2), GET_SCAN_RESULTS_SSID_MAC_LENGTH);
    break;

    case HCI_CMND_SIMPLE_LINK_START:
    break;

    case HCI_NETAPP_IPCONFIG:

    //Read IP address
    STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_IP_LENGTH);
    RecvParams += 4;

    //Read subnet
    STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_IP_LENGTH);
    RecvParams += 4;

    //Read default GW
    STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_IP_LENGTH);
    RecvParams += 4;

    //Read DHCP server
    STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_IP_LENGTH);
    RecvParams += 4;

    //Read DNS server
    STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_IP_LENGTH);
    RecvParams += 4;

    //Read Mac address
    STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_MAC_LENGTH);
    RecvParams += 6;

    //Read SSID
    STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_SSID_LENGTH);

    }
    }

    if (usReceivedEventOpcode == tSLInformation.usRxEventOpcode)
    {
    tSLInformation.usRxEventOpcode = 0;
    }
    }
    else
    {
    pucReceivedParams = pucReceivedData;
    STREAM_TO_UINT8((CHAR *)pucReceivedData, HCI_PACKET_ARGSIZE_OFFSET, ucArgsize);

    STREAM_TO_UINT16((CHAR *)pucReceivedData, HCI_PACKET_LENGTH_OFFSET, usLength);

    // Data received: note that the only case where from and from length
    // are not null is in recv from, so fill the args accordingly
    if (from)
    {
    STREAM_TO_UINT32((CHAR *)(pucReceivedData + HCI_DATA_HEADER_SIZE), BSD_RECV_FROM_FROMLEN_OFFSET, *(UINT32 *)fromlen);
    memcpy(from, (pucReceivedData + HCI_DATA_HEADER_SIZE + BSD_RECV_FROM_FROM_OFFSET) ,*fromlen);
    }

    memcpy(pRetParams, pucReceivedParams + HCI_DATA_HEADER_SIZE + ucArgsize,
    usLength - ucArgsize);

    tSLInformation.usRxDataPending = 0;
    }

    tSLInformation.usEventOrDataReceived = 0;

    SpiResumeSpi();

    // Since we are going to TX - we need to handle this event after the
    // ResumeSPi since we need interrupts
    if ((*pucReceivedData == HCI_TYPE_EVNT) &&
    (usReceivedEventOpcode == HCI_EVNT_PATCHES_REQ))
    {
    hci_unsol_handle_patch_request((CHAR *)pucReceivedData);
    }

    if ((tSLInformation.usRxEventOpcode == 0) && (tSLInformation.usRxDataPending == 0))
    {
    return NULL;
    }
    }
    }

    }

  • hello again

    I'm Juan Pedro, I working with msp430fr5739  and cc3000, over iar 6.20
    I have the same problem, I can not exit the loop, does not accept my solutions, has explain my reasoning you.

    This is the loop: and i will explain

    if (ulSpiIRQState)  

    THE VALUER OF ulSpiIRQState = 0, involves entering into de loop, where tSSLInfrmation.ReadWlanInterrupPin() ==0.

    Here is the problem, I have the board conected with the computer , I can not send anything through the port of entry because the debugger is working.

    I tried 3 different ways out, and all are wrong, someone could explain me because they are wrong?

    {
    // wait till the IRQ line goes low
    while(tSLInformation.ReadWlanInterruptPin() != 0)
    {

    }
    }
    else
    {
    // wait till the IRQ line goes high and than low
    while(tSLInformation.ReadWlanInterruptPin() == 0)
    {
    turnLedOn(1);
    //P2IN |= BIT3; // TO GO OUT THE LOOP***************************** 1º
    //tSLInformation.ReadWlanInterruptPin()=1;*****2
    goToOutTheLoop(); ***************************************3
    }

    while(tSLInformation.ReadWlanInterruptPin() != 0)
    {
    }
    }

    the Fist,  modify the registry value that allows me to leave;

    P2IN |= BIT3; // TO GO OUT THE LOOP

    Error[Pe137]: expression must be a modifiable lvalue C:\Documents and Settings\Juan Pedro\Escritorio\TodoMio\wlan.c 519

    the second modify the struct : 

    tSLInformation.ReadWlanInterruptPin()=1,;

    the  involved function is:


    //*****************************************************************************
    //
    //! ReadWlanInterruptPin
    //!
    //! @param none
    //!
    //! @return none
    //!
    //! @brief return wlan interrup pin
    //
    //*****************************************************************************

    long ReadWlanInterruptPin(void)
    {
    return (P2IN & BIT3);
    }

    this is the error:

    Error[Pe137]: expression must be a modifiable lvalue C:\Documents and Settings\Juan Pedro\Escritorio\TodoMio\wlan.c 520

    and the last 

    I have a new subrutine:

    goToOutTheLoop(); 

    /*****************************************************************************
    //
    //! GoToOutThe Loop
    //!
    //! @param none
    //!
    //! @return the port valuer
    //!
    //! @brief Go Out the loop, the last resource
    //!
    //
    //*****************************************************************************
    long goToOutTheLoop(void)
    {
    return (P2IN |= BIT3);
    }

    Similar to other rutines what working and the error is the same as the first.

    Thanks for the help

    Juan Pedro