4 Replies Latest reply on Jan 29, 2020 3:55 AM by BiBr_4596811

    Standard C function like strtok, memcpy not working

    BiBr_4596811

      I am using PSOC 4.2 for CY8C4147AZI-S445 with compiler ARM GCC 5.4-2016-q2-update.

      When I used strtok, and memcpy, the program execution stops.

      I included files as follows

      #include <stdbool.h>

      #include <stdint.h>

      #include <string.h>

      #include <stdio.h>

      #include <stdlib.h>

      #include <ctype.h>

       

      please help me why I can't use them directly.

      Thank You

      Bivay

        • 1. Re: Standard C function like strtok, memcpy not working
          AashitaR_11

          Hi BiBr_4596811,

           

           

          As per the information shared, you have already included the header file(<string.h>), which contains strtok and memcpy functions.

           

           

          Can you please let me know if you are getting any warnings when you build your project?

           

           

          Also, you have mentioned that the program execution stops. Can you try entering Debug mode and send a screenshot of the call stack so that we can get to know where exactly it stopped.

           

           

          Can you please share your project? This will help us get more insights of the issue you are facing.

           

           

          Regards,

          Aashita

          • 2. Re: Standard C function like strtok, memcpy not working
            BiBr_4596811

            cypress stuck.jpeg

             

            Thanks Aashita for reply.

            In debugging I reached above place.

            I also didn't get any warning regarding this issue.

             

            when I included source code of strtok in same c file and also includes above header files. then code not stuck. I surprised that there is no duplication error of function. I done same for memcpy, and it works.

             

            Please help if you have any idea regarding it.

            May be there will no source definition for these functions or may be not defined in compilation.

            Have I to declare some define in compiler setting to access them?

             

            Thank You

            Bivay

             

             

             

            • 3. Re: Standard C function like strtok, memcpy not working
              AashitaR_11

              Hi BiBr_4596811,

               

               

              Thanks for sharing the screenshot. This error occurs generally when you are trying to access a memory which is not allotted or if there is a stack/heap overflow.

               

              I used the device CY8C4245AXI-483 to run a similar code using PSoC Creator 4.3 to see if I can reproduce the issue from my end. I was able to program and execute the code successfully.

               

              I have attached my project. Can you please try executing the project and let me know if you are facing the same issue?

               

              If the problem continues, can you please share your project?

               

               

              Regards,

              Aashita

              2 of 2 people found this helpful
              • 4. Re: Standard C function like strtok, memcpy not working
                BiBr_4596811

                Thanks again Aashita.

                 

                Sorry I am not able to post the code as it is ported code from other controller and remove extra parts is, too lengthy , but I will try your code to get error.

                I also get same issue if I use localtime() function from time.h

                 

                Thanks

                Bivay