Psoc 5LP Custom Function return error

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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello,

   

We are currently working on a project that is creating a small autonomous vehicle. We are having trouble executing multiple functions that we have written. We are able to execute one full forward function but never return to our main to run the reverse function. Upon debugging we found that we get stuck in a while loop located in Cm3start.c file.  Any ideas/suggestions as to why we are never returning to our main code after completing one movement function?  All help is greatly appreciated.  The File for our project is attached.

   

Thank you,

   

Richard

0 Likes
3 Replies
Anonymous
Not applicable

I think there's a fault in one of your move functions.. The quadrature decoders generate positive or negative values depending on which direction your motors have spun. This means that one or the other of the while loops will never end in user_movement_functions.c (EDIT: or to be more accurate, it won't end the way you expect it to).

   

The other thing that strikes me is that there is no endless loop in your main() function. When your code finishes executing, main() returns, and you will wind up in Cm3Start.c at lines 387-390 in the following code:

   

while (1)
{
    /* If main returns, make sure we don't return. */
}

   

I'd suggest putting the following part of your main() function in an endless loop like so:

   

    while(1)

   

    {

   

        Move_Forward(50,(2*1920));
        Move_Reverse(150,(2*1920));
        CyDelay(5000); 
    }

0 Likes
Anonymous
Not applicable

Thank you PolyVinalDistillat. That fixed our problem. For the Negitive values of the reverse function we are going to edit the code to take that absolute value of the encoder reading.

0 Likes
Anonymous
Not applicable

Glad to have helped 🙂

0 Likes