2 Replies Latest reply on Oct 4, 2018 9:18 AM by jlister_1418221

    PSOC 4 Infinite Loop at if(errno == ENOMEM)

    jlister_1418221

      I have what is hopefully an easy problem to solve: How do I figure out why I am stuck here?

       

      Using some breakpoints and stepping, I've discovered about where in my code I get kicked over into this handler, I just don't know what the exact cause is. My project has an OLED display that I have to map out (SSD1306, it requires a char array[4][128]). The project has three display modes, a standard display, a menu selection, and some input data (which is displayed as you key in the input). Things work fine in the standard display mode and menu selection mode.

      When it comes time to build the OLED map for the input data mode, I keep getting kicked into the handler. Specifically, during the process of 'building' the map. I have a 3D array[12][4][20] full of the maps for various characters(stored in Flash as it overran the SRAM when I originally stored it there). The code copies the required character maps from that 3D array into the appropriate locations of the OLED display's map array. Below is the code snippet where it breaks on me. d1top is 0 and d1bottom is 20. I've stepped through, and things work great there. The issue is right when it transitions to add the second digit.

       

      Last bit of information, this is almost identical to the function used to display the standard display mode and menu selection mode. Since this is the input data mode, I had to modify the function input parameters and hard code in

      displayData[page][i] = digit[10][page][placeholder];

      instead of

      displayData[page][i] = digit[d1][page][placeholder];

      There are other minor differences, but that's the only thing involved in this section of the function. The function that runs the other two modes works great.

       

      When I try to add errno to the Watch list it just says that 'errno' does not exist in the current context, so I can't get any further information from there.

       

      I also changed up the code where the functions are now passed a pointer to the display array (displayData[][]). Before I would just create a new one in each function and send the entire array to the display function. Since the only thing I have to go on is ENOMEM, I thought maybe I had ran out of SRAM, but now that I'm just passing the address to the two different functions (the one for the standard and menu, and then this one for the input data) I'm still getting kicked into this loop.

       

      for(page = 0; page < 4; page++)

          {

             

              //

              //clears entire display

              //

              for(initLoop = 0; initLoop < 128; initLoop++)

              {

                  displayData[page][initLoop] = 0x00;

              }                                              //reset placeholder

             

              //

              //add digit in first place to display map

              //

              for(i = d1top; i < d1bottom; i++)

              {

                  displayData[page][i] = digit[10][page][placeholder];

                  placeholder++;

              }

             

              placeholder = 0;                                                //reset placeholder

             

              //

              //add digit in second place to display map

              //

              for(i = d2top; i < d2bottom; i++)

              {

                  displayData[page][i] = digit[d2][page][placeholder];

                  placeholder++;

              }

             

              placeholder = 0;                                                //reset placeholder

             

              //

              //add digit in third place to display map

              //

              for(i = d3top; i < d3bottom; i++)

        • 1. Re: PSOC 4 Infinite Loop at if(errno == ENOMEM)
          user_13463998

          Hi,

           

          ENOMEM seems to be out of memory.

           

          In your case I wonder what value d1 ~ d10 actually holds.

          If it is out of 0 <= dx < 11, that can be the reason.

           

          Similarly, could you test assigning a number  to d2

          before the loop using d2?

          Such as

           

          placeholder = 0 ;

          d2 = 10 ;

          for (i = d2top ; i < d2bottom ; i++ ) {

               displayData[page][i] = digit[d2][page][placeholder] ;

               placeholder++ ;

          }

           

          moto

          1 of 1 people found this helpful
          • 2. Re: PSOC 4 Infinite Loop at if(errno == ENOMEM)
            jlister_1418221

            Hey moto,

             

             

            You helped me figure it out. The dx's are digits used to input a password, so I know they are only '0'-'9' with '10' and '11' being special hardcoded characters. When I went back to copy and paste the code snippet to show you how it was assigned, I noticed that I was using pointers to the dx's and forgot to send them to this function appropriately (I was sending the address instead of the actual contents). So I was telling it to look waaay outside of bounds of that array.

             

             

            Thanks for your help! My problems are usually something simple I've overlooked, but I don't always find them on my own