Assuming t_high is a uhd::time_spec_t that marks the start time of your
HIGH state, simply do

auto t_low = t_high + 1e-6;

and then use t_low for your second timed command:

usrp->set_command_time(t_high);
usrp->set_gpio_attr(/* set your pin high */);
usrp->set_command_time(t_low);
usrp->set_gpio_attr(/* set your pin low */);

--M


On Mon, Feb 24, 2025 at 9:45 AM <kavin...@atindriya.co.in> wrote:

> Hi,
>    What is the minimum time to toggle the GPIO pin?
>    I want to make the GPIO pin high for 1microsecond and low for
> 1milliseconds. How i achieve this through code?
>
>
> Thanks.
>
>
>
> On 2025-02-24 01:57, Martin Braun wrote:
> > You don't specify a delay, you send one timed command to make the pin
> > go HIGH, and another timed command to make it go LOW. And the two
> > command-times should be "your delay" apart.
> >
> > This may help:
> >
> https://www.youtube.com/watch?v=ppD06ZETnek&t=75s&pp=ygUPZ3Jjb24gdXNycCBncGlv
> >
> > --M
> >
> > On Sat, Feb 22, 2025 at 12:12 PM <kavin...@atindriya.co.in> wrote:
> >
> >> Hi,
> >> How to give the delay in
> >> uhd_usrp_set_command_time(uhd_usrp_handle
> >> h,int64_t full_secs,double frac_secs,size_t mboard) function?
> >>
> >> On 2025-02-22 00:10, Marcus D. Leech wrote:
> >>> On 21/02/2025 23:56, kavin...@atindriya.co.in wrote:
> >>>> Hi,
> >>>> Can I use usleep(1) or any other technique is there for GPIO .
> >>>>
> >>> You might be able to use timed commands:
> >>>
> >>>
> >>
> > https://files.ettus.com/manual/page_timedcmds.html#timedcmds_gen_cmds
> >>>
> >>> But since usleep() cannot guarantee any kind of maximum period
> >> that
> >>> your process will go to sleep, it is an unreliable
> >>> method when precision and repeatable timing of ANY kind of
> >> "doing
> >>> stuff with external hardware" is required.  Even if
> >>> usleep() at microsecond-scale intervals *WAS* reliable and
> >>> repeatable, there's no guarantee about all the *other* things
> >>> that are required to launch a command over a
> >> latency-not-guaranteed
> >>> bus to the external hardware, including kernel-layer
> >>> USB drivers, etc, etc.
> >>>
> >>>
> >>>>
> >>>> On 2025-02-21 23:37, Marcus D. Leech wrote:
> >>>>> On 21/02/2025 23:22, kavin...@atindriya.co.in wrote:
> >>>>>> Hi,
> >>>>>> Thanks for answering.
> >>>>>> Can you explain me clearly?
> >>>>>>
> >>>>>> Thanks.
> >>>>> I'd suggest, at a minimum, looking at the MAN page for usleep().
> >>>>>
> >>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> On 2025-02-21 23:11, Marcus D. Leech wrote:
> >>>>>>> On 21/02/2025 23:05, kavin...@atindriya.co.in wrote:
> >>>>>>>> Hi,
> >>>>>>>> In USRP B205mini-i I am able to access the GPIO Pin. I
> >> have to
> >>>>>>>> create a Pulse in the GPIO pin. I want to make high the gpio
> >> pin
> >>>>>>>> for 1microsecond and low for 999microseconds. How to achieve
> >> this
> >>>>>>>> timings through coding. Can you give me the solution for
> >> this?
> >>>>>>>>
> >>>>>>>> In coding after making high I am giving usleep(1) function
> >> but
> >>>>>>>> when I am check in the oscilloscope it is showing
> >> 64microseconds.
> >>>>>>>> How?
> >>>>>>>>
> >>>>>>>>
> >>>>>>> Because an application-land program executing on an ordinary
> >>>>>>> general-purpose operating system is unlikely to be able to
> >>>>>>> achieve repeatable, 1usec-scale timing.  This has nothing to
> >> do,
> >>>>>>> per se, with UHD or USRPs, but rather, to understanding
> >>>>>>> how applications execute in a general-purpose operating
> >> system
> >>>>>>> that isn't ruthlessly optimized for "hard" real-time tasks.
> >>>>>>>
> >>>>>>>
> >>>>>>> _______________________________________________
> >>>>>>> USRP-users mailing list -- usrp-users@lists.ettus.com
> >>>>>>> To unsubscribe send an email to
> >> usrp-users-le...@lists.ettus.com
> >>>>> _______________________________________________
> >>>>> USRP-users mailing list -- usrp-users@lists.ettus.com
> >>>>> To unsubscribe send an email to usrp-users-le...@lists.ettus.com
> >>> _______________________________________________
> >>> USRP-users mailing list -- usrp-users@lists.ettus.com
> >>> To unsubscribe send an email to usrp-users-le...@lists.ettus.com
> >> _______________________________________________
> >> USRP-users mailing list -- usrp-users@lists.ettus.com
> >> To unsubscribe send an email to usrp-users-le...@lists.ettus.com
> > _______________________________________________
> > USRP-users mailing list -- usrp-users@lists.ettus.com
> > To unsubscribe send an email to usrp-users-le...@lists.ettus.com
>
_______________________________________________
USRP-users mailing list -- usrp-users@lists.ettus.com
To unsubscribe send an email to usrp-users-le...@lists.ettus.com

Reply via email to