FX3/CX3(CYUSB3065) thread stop problem

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

cross mob
YaXi_4492421
Level 2
Level 2
10 replies posted 10 questions asked 5 replies posted

I use FX3/CX3(CYUSB3065) to shoot through DMA,

and then use a set of I2C to control the configuration of the camera.

The I2C also controls another chip, which requires occasional access,

Then the thread stopped being turned on (and the camera stopped),

and I added CyU3PMutexGet and CyU3PMutexPut before and after I2C to no avail.

What is the reason? Is there any way to solve it?

0 Likes
8 Replies
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi,

Please let me know how did you confirm that the thread is not running?

Can you please share your firmware?

Regards,

Hemanth

Hemanth
0 Likes

I created a thread with a while loop in the thread callback:

void vThTimer200Ms( uint32_t input)

{

while(1)

{

CyU3PDebugPrint (4, "\n 11111111\n");

CyU3PI2cReceiveBytes(preamble,data,byteCount,retryCount);

CyU3PThreadSleep(200);

}}

The LOG of this thread is no longer printed, the oscilloscope measurement of I2C is no waveform transformation, the output to PC video is stopped, and the LOG in esUVCUvcAppThread_Entry thread is no longer printed.

0 Likes
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi,

The above function looks like a timer callback function. Try not to block the Timer callback as above. Just update a flag variable to CyTrue in the Timer Callback. Then based on that variable being CyTrue/CyFalse perform prints/I2C Transfers in the for(;;) in the Thread_Entry.

That is:

void vThTimer200Ms( uint32_t input)

{

     gl_timer_callback = CyTrue;

}

In your Thread_Entry for(;;), you can do below:

for (;;)

{

     ...

     ...

     if(gl_timer_callback == CyTrue)

     {

          CyU3PTimerStop(...);

          CyU3PTimerModify(...);

          CyU3PTimerStart(...);

          CyU3PDebugPrint (4, "\n 11111111\n");

          CyU3PI2cReceiveBytes(preamble,data,byteCount,retryCount);

          CyU3PThreadSleep(200);

          gl_timer_callback = CyFalse;

     }

     ...

     ...

}

Regards,

Hemanth

Hemanth
0 Likes

Thank you for your reply, but I still haven't solved it:

This is not a timer callback, this is a callback that creates a thread in the thread. Therefore, there is no timer block.

My problem is that this one thread operates on I2C, and then both the thread and Thread_Entry stop. (sometimes several cycles before stopping)

0 Likes
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi,

Please share your firmware.

Regards,

Hemanth

Hemanth
0 Likes

Here's my code:

void vThTimer200Ms( uint32_t input)

{

CyU3PThreadSleep(3000); // wait for init finish

while(1)

{

                                CyU3PDebugPrint (4, "\n 11111111\n");

CyU3PI2cReceiveBytes(preamble,data,byteCount,retryCount);

CyU3PThreadSleep(200);

}

   }

void vThCreatTestThread(void)

{

void *ptr = NULL;

     uint32_t retThrdCreate = CY_U3P_SUCCESS;

     /* Allocate the memory for the thread and create the thread */

     ptr = CyU3PMemAlloc (UVC_APP_THREAD_STACK);

     retThrdCreate = CyU3PThreadCreate (&thWdt,   /* UVC Thread structure */

             "101:th_Wdt",         /* Thread Id and name */

             vThTimer200Ms,          /* UVC Application Thread Entry function */

             0,                           /* No input parameter to thread */

             ptr,                         /* Pointer to the allocated thread stack */

             THREAD_STACK_TEST,        /* UVC Application Thread stack size */

             THREAD_PRIORITY_TEST,     /* UVC Application Thread priority */

             THREAD_PRIORITY_TEST,     /* Pre-emption threshold */

             CYU3P_NO_TIME_SLICE,         /* No time slice for the application thread */

             CYU3P_AUTO_START             /* Start the Thread immediately */

             );

     /* Check the return code */

     if (retThrdCreate != 0)

     {

         /* Thread Creation failed with the error code retThrdCreate */

         /* Add custom recovery or debug actions here */

         /* Application cannot continue */

         /* Loop indefinitely */

         while(1);

     }

}

0 Likes
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Can you try creating this thread in CyFxApplicationDefine() (instead of creating it in your existing application thread) -- as done in many Cypress Example codes?


Regards,

Hemanth

Hemanth
0 Likes

Thank you for your patient answer, let me describe some of question:

I created this thread in CyFxApplicationDefine(), and the rest of the code is sample code (except for the GPIO control).

My program has only two things: a 1080P USB3.0 camera and this one that reads data via I2C.

So my program has only two threads: vThTimer200Ms and esUVCUvcAppThread_Entry.

(because I am not authorized to send the code to the outside of the company, I can only describe it, please understand.)

So, what's the reason? Or how to avoid it?

0 Likes