5 Replies Latest reply on Jul 31, 2018 2:16 AM by JoMe_264151

    Error - program stucks in infinite loop

    ChGa_3545231

      Hi there,

       

      my program stucks right at the beginning.

      I start the initialization and right it jumps into a infinite loop.

       

      CY_NORETURN

      CY_ISR(IntDefaultHandler)

      {

          /***************************************************************************

          * We must not get here. If we do, a serious problem occurs, so go into

          * an infinite loop.

          ***************************************************************************/

       

       

          #if defined(__GNUC__)

              if (errno == ENOMEM)

              {

                  #ifdef CY_BOOT_INT_DEFAULT_HANDLER_ENOMEM_EXCEPTION_CALLBACK

                      CyBoot_IntDefaultHandler_Enomem_Exception_Callback();

                  #endif /* CY_BOOT_INT_DEFAULT_HANDLER_ENOMEM_EXCEPTION_CALLBACK */

                 

                  while(1)

                  {

                      /* Out Of Heap Space

                       * This can be increased in the System tab of the Design Wide Resources.

                       */

                  }

              }

       

      I don't know what to do here.

       

      Thanks

        • 1. Re: Error - program stucks in infinite loop
          JoMe_264151

          Chrisse, I suppose the printf() call sends your project into electronic nirwana. There is no OS in thePSoC, so how should the compiler know that you want to send the data to a component named UART.

          Use sprintf() to format your data and UART_PutString() API to send the data.

           

          Happy coding

          Bob

           

          PS: Where in Germany are you located? I live near Bremen

          • 2. Re: Error - program stucks in infinite loop
            ChGa_3545231

            Hi Bob,

             

            after reading this comment I feel like dumbass.

            Thanks for your response.

             

            I live in Austria, Innsbruck.

             

            Chris

            • 3. Re: Error - program stucks in infinite loop
              JoMe_264151

              Chris, I am just a bit older than you,. That doesn't mean I am wiser, it only means I've made more errors than you did. ;-)

               

              Bob

              • 4. Re: Error - program stucks in infinite loop
                ChGa_3545231

                That's right.

                 

                That is why I could need some extra help.

                The code is for a project on which I am working at the moment.

                 

                I am trying to establish a connection between my PSOC and a BlueRadios Sensor -Sensorbug-.

                After establishing the connection the next thing would be to read out the light data which the sensor measures.

                 

                I am trained in C and learned - learning it in school and so I thought I could do this without a problem.

                But I realized pretty soon that I was wrong especially the API's for the BLE Kit are driving me crazy.

                 

                So I tried to establish the connection with my code, which I posted already, but it won't connect.

                And I am coming to a point where I don't know what to do anymore, I am stuck and would need some help.

                My code always stops at the same position.

                 

                void CustomEventHandler(uint32 event, void * eventParam)

                {

                   

                   /*Declaring Local variables*/

                    uint8 i;

                    CYBLE_GAPC_ADV_REPORT_T scanReport;

                    CYBLE_API_RESULT_T apiResult;  

                    char varhandler [30];

                  

                    switch(event)

                    {      

                        case CYBLE_EVT_STACK_ON:

                               

                                sprintf(varhandler, "BLE Stack ON:\r\n");

                                UART_PutString(varhandler);

                               

                                //printf("BLE Stack ON:\r\n");

                               

                                /*Start to Scan after Stack ON*/

                                CyBle_GapcStartScan(CYBLE_SCANNING_FAST);

                            break;                  

                           

                        case CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

                                scanReport=  *(CYBLE_GAPC_ADV_REPORT_T*)eventParam;

                                

                                /*Check for the Manufacturer specific data in scan response*/

                                if(scanReport.data[1] == MANUFACTURER_SPECIFIC_DATA && scanReport.data[2] == COMPANY_LSB && scanReport.data[3] == COMPANY_MSB

                                && scanReport.data[4] == MAN_SPEC_DATA_LSB && scanReport.data[5] == MAN_SPEC_DATA_MSB)

                                {

                                    sprintf(varhandler, "peer address:\r\n");

                                    UART_PutString(varhandler);

                               

                                    //printf("peer address:\r\n");

                                   

                                    for(i=0;i<CYBLE_GAP_BD_ADDR_SIZE;i++)

                                    {

                                        peerDeviceAddr.bdAddr[i]=scanReport.peerBdAddr[i];

                                       

                                        sprintf(varhandler, "%2.2x",scanReport.peerBdAddr[CYBLE_GAP_BD_ADDR_SIZE-1-i]);

                                        UART_PutString(varhandler);

                                       

                                        //printf("%2.2x",scanReport.peerBdAddr[CYBLE_GAP_BD_ADDR_SIZE-1-i]);

                                    }

                                   

                                    sprintf(varhandler, "\r\n");

                                    UART_PutString(varhandler);

                                   

                                    //printf("\r\n");

                                    deviceDetected=TRUE;

                                   

                                    /*Start to scan after disconnection*/

                                    CyBle_GapcStopScan();

                                }

                                

                            break;

                               

                        case CYBLE_EVT_GAPC_SCAN_START_STOP:

                               

                                if(CyBle_GetState()==CYBLE_STATE_SCANNING)

                                {

                                    sprintf(varhandler, "Started to Scan\r\n");

                                    UART_PutString(varhandler);

                                   

                                    //printf("Started to Scan\r\n");

                                }

                                else if(CyBle_GetState()==CYBLE_STATE_DISCONNECTED)

                                {   

                                    sprintf(varhandler, "Stop scanning:\r\n");

                                    UART_PutString(varhandler);

                                   

                                    //printf("Stop scanning:\r\n");

                                   

                                    if(deviceDetected==TRUE)

                                    {

                                        apiResult=CyBle_GapcConnectDevice(&peerDeviceAddr);

                                        if(apiResult==CYBLE_ERROR_OK)

                                        {

                                            sprintf(varhandler, "success\r\n");

                                            UART_PutString(varhandler);

                                           

                                            //printf("success\r\n");

                                        }

                                        else

                                        {

                                            sprintf(varhandler, "connection failed:%x\r\n",apiResult);

                                            UART_PutString(varhandler);

                                           

                                            //printf("connection failed:%x\r\n",apiResult);

                                        }

                                        deviceDetected=FALSE;  

                                    }

                                }

                            break;

                       

                         case CYBLE_EVT_GAP_DEVICE_CONNECTED:

                                /*Start to dicovery the servioes of the serve after connection*/

                                CyBle_GattcStartDiscovery(cyBle_connHandle); 

                            break;

                               

                        case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:          

                                /*Start to scan after disconnection*/

                                CyBle_GapcStartScan(CYBLE_SCANNING_FAST);

                            break;

                               

                        case CYBLE_EVT_GATTC_DISCOVERY_COMPLETE:

                                

                                sprintf(varhandler, "\r\n");

                                UART_PutString(varhandler);

                               

                                //printf("\r\n");

                               

                                sprintf(varhandler, "Discovery complete.\r\n");

                                UART_PutString(varhandler);

                               

                                //printf("Discovery complete.\r\n");

                               

                                for(i = 0u; i < CYBLE_SRVI_COUNT; i++)

                                {         

                                    /*Checking for the Tx power service*/

                                    if(cyBle_serverInfo[i].uuid == CYBLE_UUID_TX_POWER_SERVICE)

                                    {

                                        if(cyBle_serverInfo[i].range.startHandle < cyBle_serverInfo[i].range.endHandle)

                                        {

                                            sprintf(varhandler, "Peer device supports Tx power Service \r\n");

                                            UART_PutString(varhandler);

                               

                                            //printf("Peer device supports Tx power Service \r\n");     

                                        }

                                        else

                                        {

                                            sprintf(varhandler, "Peer device doesn't supports Tx power Service \r\n");

                                            UART_PutString(varhandler);

                                           

                                            //printf("Peer device doesn't supports Tx power Service \r\n");

                                        }

                                    }

                 

                 

                                }   

                                sprintf(varhandler, "\r\n");

                                UART_PutString(varhandler);

                               

                                //printf("\r\n");

                            break;                  

                               

                        default:              

                             break;

                               

                    }

                }

                 

                It always tries to match the given MSD with the ones he reads. But they don't match and I don't know why. Espescially because I don't know what that data is for and what exactly to give in. I tried to read it out of the datasheet but there is some data called MSD but not company specific data and manufactuerer specific data.

                 

                Thanks

                Chris

                • 5. Re: Error - program stucks in infinite loop
                  JoMe_264151

                  I am not good in giving advices for BLE.

                  I would suggest you to re-post your actual question as a new topic.

                  Nobody tends to like reading lengthy code without the help of an IDE. So best for getting help id to post a complete project. To do so, use

                  Creator->File->Create Workspace Bundle (minimal)

                  and attach the resulting file.

                   

                  Bob