CX3 UVC: DMA reset is not always initiated when the sensor stops sending data

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

cross mob
ajmc_3522501
Level 3
Level 3
5 likes given First like given

Hi All,

I'm using the CX3 chip to stream data from my custom sensor via USB 3.0.

Sometimes my sensor stops sending data at that point i need to restart the streaming.

I was making use of the "CX3_DMA_RESET_EVENT" which will be triggered by a timer when a frame is not received in time.

But during testing i found out that this is not working always. The timer is not always triggered when the streaming stops.

Could you please help me out here.

Regards

Ajay

0 Likes
1 Solution

Please try Stop, Modify and Start the timer in Producer_Event for a Partial DMA buffer (i.e. End of Frame) and check.

Sample Snippet:

/* Add Headers*/

            if (dmaBuffer.count < CX3_APP_DATA_BUF_SIZE)

            {

                CyCx3AppAddHeader ((dmaBuffer.buffer - CX3_APP_PROD_HEADER), CX3_APP_HEADER_EOF);

#ifdef RESET_TIMER_ENABLE

                /* We got another end of frame packet. Restart the timer here. */

                CyU3PTimerStop (&Cx3ResetTimer);

                CyU3PTimerModify (&Cx3ResetTimer, TIMER_PERIOD, 0);

                CyU3PTimerStart (&Cx3ResetTimer);

#endif

            }

View solution in original post

9 Replies
KandlaguntaR_36
Moderator
Moderator
Moderator
25 solutions authored 10 solutions authored 5 solutions authored

Please print the timer value continously in main thread and check whether TimerCb is calling after time out.

You may put a flag in TimerCb and print it in the main thread when the flag is set.

Please refer the Ov5640 example firmware and implement the same mechanism.

0 Likes

Is there an API to get the timer value?

I checked the callback function and it is not getting invoked.

I'm using the firmware based on the OV5640 example.

The callback is working sometimes and i'm able to restart streaming, but not always.

Regards

Ajay

0 Likes

Use this API CyU3PGetTime

Please avoid DebugPrints in Call back functions. Remove them, if you are using any.

0 Likes

I'm not using debug prints in the callback functions, Thanks for the info.

The CyU3PGetTime API only returns the elapsed timer ticks since startup. That number keeps on increasing. I'm printing that value and checking whether callback was invoked.

Even after the time out period the callback is not getting invoked.

0 Likes

Please share the uvc.c file to check how you are handling the timer.

0 Likes

Please find attached the uvc file used.

0 Likes

Please try Stop, Modify and Start the timer in Producer_Event for a Partial DMA buffer (i.e. End of Frame) and check.

Sample Snippet:

/* Add Headers*/

            if (dmaBuffer.count < CX3_APP_DATA_BUF_SIZE)

            {

                CyCx3AppAddHeader ((dmaBuffer.buffer - CX3_APP_PROD_HEADER), CX3_APP_HEADER_EOF);

#ifdef RESET_TIMER_ENABLE

                /* We got another end of frame packet. Restart the timer here. */

                CyU3PTimerStop (&Cx3ResetTimer);

                CyU3PTimerModify (&Cx3ResetTimer, TIMER_PERIOD, 0);

                CyU3PTimerStart (&Cx3ResetTimer);

#endif

            }

Thanks for helping me.

I have solved my issue.

The solution you have suggested will also work, but i have done it a little differently.

The existing timer that initiates a DMA reset was used to check if a frame transfer was completed in time , else a callback would be invoked.

My condition was sometimes the sensor stream stream stops after frame end and not in between. This way the timer would never be invoked.

What i did was to create another timer so that this problem is addressed. I started the timer when a frame has completed transferring and stopped it when next frame has started. Thus i could know whether there was a huge time gap between successive frames and trigger a DMA reset if needed.

Regards

Ajay

0 Likes