toggle sequence gets stretched

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.
Aniket_
Level 2
Level 2
10 replies posted 25 sign-ins First like given

Hello,

I am using GPIO pins to generate some on off sequence on pin. But while generating it sometimes my sequence gets stretched as attached in file. here i am using Simple GPIO.

I am using for loop for the same.

for(i=0; i<=7; i++)
{
CyU3PGpioSimpleSetValue(45,CyTrue);
CyU3PBusyWait (1);
CyU3PGpioSimpleSetValue(45,CyFalse);
CyU3PBusyWait (1);
}

 

Let me know what i am missing.

0 Likes
1 Solution
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Aniket,

I discussed the issue internally.

If a simple GPIO is used to create such a train of pulses of high frequency, the thread switching by the scheduler on the RTOS may cause some latency in servicing the thread created in the application firmware. This may be the reason of seeing such stretches.

Can you use Complex GPIOs for your application? You can create a PWM for a certain amount of time, for this purpose.

Best Regards,
AliAsgar

 

View solution in original post

0 Likes
11 Replies
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi,

Could you let me know if there are any other operations in the firmware? For ex., is any DMA transfer taking place etc., when the GPIO on off sequence is executing?

Can you let me know if a similar issue is happening if CyU3PThreadSleep(1) is used for delay (1 millisecond)?

Also instead of CyU3PBusyWait(), try using a loop to introduce a delay and let me know if the issue is seen.

Best Regards,
AliAsgar

0 Likes
Aniket_
Level 2
Level 2
10 replies posted 25 sign-ins First like given

Hello AliAsgar,

1. when the GPIO on off sequence is executing at that time there is no any operation is going on in the firmware.
2. yes similar issue is happening if CyU3PThreadSleep(1) is used for delay.
3. we tried the delay with the for loop instead of  CyU3PBusyWait() but we are facing same issue with this.

Regards,
Aniket

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Aniket,

Can you share the waveforms with points 2 and 3 as well?

Best Regards,
AliAsgar

0 Likes
lock attach
Attachments are accessible only for community members.
Aniket_
Level 2
Level 2
10 replies posted 25 sign-ins First like given

Hello AliAsgar,

PFA for the same. 

Regards,

Aniket Patil.

 

 

 

    

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Aniket, 

I do not see any significant issue with Point2 photos. 

Is the same issue reproducible with any other GPIO's apart from GPIO45?

Best Regards,
AliAsgar

0 Likes

Hi AliAsgar,

As for point 2 we are using CyU3PThreadSleep(1) [which is 1 ms delay] and stretching is happening in few us order.  hence it is not visible directly but if we check with total timing for each sequence and time difference between ON and OFF cycle it is not constant.

Yes same issue is happening in any other GPIO's apart from GPIO45.

Regards,

Aniket

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Aniket,

I used the firmware you sent to program FX3 and probe the GPIO45 line. I was not able to reproduce the issue. I was getting a constant train of pulses on GPIO45.

Could you share with us the schematics and the send the photo of the setup you have at your end?

Is this issue happening with all the FX3 chips you have?

Best Regards,
AliAsgar

0 Likes

Hi AliAsgar,

Are you trying it multiple time? As it gets generated sometimes (Random).

I have checked with 4-5 chips i am getting same result.

I have USB FX3 SuperSpeed Explorer Kit on that also i am getting same response.

Regards,

Aniket

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Aniket,

I discussed the issue internally.

If a simple GPIO is used to create such a train of pulses of high frequency, the thread switching by the scheduler on the RTOS may cause some latency in servicing the thread created in the application firmware. This may be the reason of seeing such stretches.

Can you use Complex GPIOs for your application? You can create a PWM for a certain amount of time, for this purpose.

Best Regards,
AliAsgar

 

0 Likes

Hello AliAsgar,

As I am using only one thread still thread switching will happen?

I am trying with Complex PWM. I am able to control Pulse width and Pulse frequency with that I am able to generate continuous pulses but I want to control its occurrence as per requirement (like  8, 16 or 24 times pulse). Let me know how to control it. How to use interrupt in complex PWM?

 

Regards,

Aniket Patil

0 Likes
lock attach
Attachments are accessible only for community members.
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Aniket,

There are multiple threads running in the RTOS, apart from the threads running in the application firmware.

USB, DMA etc have their own threads running which are created inside their initialization functions.

The CyU3PGpioInit takes the second parameter as a GPIO interrupt callback function.
The intrMode for the ComplexGpio can be set as either timer_thres or timer_zero and the PWM can be stopped inside the callback function after some pulses.

Please refer to the attached firmware for implementation reference.

Note that, as PWM is CPU independent, Even during the handling of the GPIO callback, PWM will still be running, thus resulting in some extra pulses.

Best Regards,
AliAsgar

0 Likes