Standard C function like strtok, memcpy not working

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
BiBr_4596811
Level 2
Level 2
5 replies posted 5 questions asked 5 sign-ins

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

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

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

View solution in original post

4 Replies
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

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

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

0 Likes
lock attach
Attachments are accessible only for community members.

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

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

0 Likes