On the fly change in high frequecy clock pulse
Posted: Thu May 18, 2017 1:47 pm
Hello,
I am trying to use a while(1) select case timerafter(time) controlled loop to toggle a gpio pin (port <: 1 or port <: 0) in each consecutive iteration of the loop by adding a delay value to this time.Basically generating a clock pulse.
My end use is to drive a gpio at both high and low frequency but I want a fast response in its change at both high and low frequency. With my current methodology I call an interface by using select case and change the delay value by that.So my response time in the change is dependent on the delay of my loop which creates a lag in change of frequency at lower sides(for my use case lag is as high as 0.3 seconds). Is there a work around over which I can keep running a gpio and change its frequency without having to wait for my delay time.
Also the code works without any issues for lower frequency but as soon as I go for a delay in looptime to be less than 6 microseconds, the code doesn't run and ET error is shown with error line pointing to the port <: 0 line(I believe the time taken by <: command is more than my loop time so its getting stuck).
Is there anyway we can use timers to toggle the gpio with on the fly changing frequency of my pulse by using clocks.
I am trying to use a while(1) select case timerafter(time) controlled loop to toggle a gpio pin (port <: 1 or port <: 0) in each consecutive iteration of the loop by adding a delay value to this time.Basically generating a clock pulse.
My end use is to drive a gpio at both high and low frequency but I want a fast response in its change at both high and low frequency. With my current methodology I call an interface by using select case and change the delay value by that.So my response time in the change is dependent on the delay of my loop which creates a lag in change of frequency at lower sides(for my use case lag is as high as 0.3 seconds). Is there a work around over which I can keep running a gpio and change its frequency without having to wait for my delay time.
Also the code works without any issues for lower frequency but as soon as I go for a delay in looptime to be less than 6 microseconds, the code doesn't run and ET error is shown with error line pointing to the port <: 0 line(I believe the time taken by <: command is more than my loop time so its getting stuck).
Is there anyway we can use timers to toggle the gpio with on the fly changing frequency of my pulse by using clocks.