usrp-users@lists.ettus.com

Discussion and technical support related to USRP, UHD, RFNoC

View all threads

REG: GPIO Toggling

K
kavinraj@atindriya.co.in
Mon, Feb 24, 2025 9:42 AM

Hi,
I have written a c code for GPIO toggling in USRP B205mini-i board.
The pin should be high for 1microseconds and low for 1milliseconds. I
have given the c code to verify whether it is correct or not?

 while(1)
 {
     uhd_usrp_get_time_now(usrp, mboard, &full_secs, &frac_secs);
     uhd_usrp_set_command_time(usrp, full_secs , frac_secs + 1e-6, 

mboard);
error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x01, mask1,
mboard);
uhd_usrp_clear_command_time(usrp, 0);
uhd_usrp_get_time_now(usrp, mboard, &full_secs, &frac_secs);
uhd_usrp_set_command_time(usrp, full_secs , frac_secs + 1e-3,
mboard);
error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x00, mask1,
mboard);
uhd_usrp_clear_command_time(usrp, 0);
}

Thanks.

Hi, I have written a c code for GPIO toggling in USRP B205mini-i board. The pin should be high for 1microseconds and low for 1milliseconds. I have given the c code to verify whether it is correct or not? while(1) { uhd_usrp_get_time_now(usrp, mboard, &full_secs, &frac_secs); uhd_usrp_set_command_time(usrp, full_secs , frac_secs + 1e-6, mboard); error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x01, mask1, mboard); uhd_usrp_clear_command_time(usrp, 0); uhd_usrp_get_time_now(usrp, mboard, &full_secs, &frac_secs); uhd_usrp_set_command_time(usrp, full_secs , frac_secs + 1e-3, mboard); error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x00, mask1, mboard); uhd_usrp_clear_command_time(usrp, 0); } Thanks.
MB
Martin Braun
Mon, Feb 24, 2025 1:17 PM

On Mon, Feb 24, 2025 at 10:42 AM kavinraj@atindriya.co.in wrote:

Hi,
I have written a c code for GPIO toggling in USRP B205mini-i board.
The pin should be high for 1microseconds and low for 1milliseconds. I
have given the c code to verify whether it is correct or not?

  while(1)
  {
      uhd_usrp_get_time_now(usrp, mboard, &full_secs, &frac_secs);
      uhd_usrp_set_command_time(usrp, full_secs , frac_secs + 1e-6,

mboard);

This won't work, you need to set this in the future from "time now".

     error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x01, mask1,

mboard);
uhd_usrp_clear_command_time(usrp, 0);
uhd_usrp_get_time_now(usrp, mboard, &full_secs, &frac_secs);
uhd_usrp_set_command_time(usrp, full_secs , frac_secs + 1e-3,
mboard);

Same here.

      error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x00, mask1,

mboard);
uhd_usrp_clear_command_time(usrp, 0);
}

Get the time "now" outside of the loop, and use that as a base reference.
When you've fixed that, I recommend you connect it to an oscilloscope for
verification.

--M

On Mon, Feb 24, 2025 at 10:42 AM <kavinraj@atindriya.co.in> wrote: > Hi, > I have written a c code for GPIO toggling in USRP B205mini-i board. > The pin should be high for 1microseconds and low for 1milliseconds. I > have given the c code to verify whether it is correct or not? > > while(1) > { > uhd_usrp_get_time_now(usrp, mboard, &full_secs, &frac_secs); > uhd_usrp_set_command_time(usrp, full_secs , frac_secs + 1e-6, > mboard); > This won't work, you need to set this in the future from "time now". error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x01, mask1, > mboard); > uhd_usrp_clear_command_time(usrp, 0); > uhd_usrp_get_time_now(usrp, mboard, &full_secs, &frac_secs); > uhd_usrp_set_command_time(usrp, full_secs , frac_secs + 1e-3, > mboard); > Same here. > error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x00, mask1, > mboard); > uhd_usrp_clear_command_time(usrp, 0); > } > Get the time "now" outside of the loop, and use that as a base reference. When you've fixed that, I recommend you connect it to an oscilloscope for verification. --M
K
kavinraj@atindriya.co.in
Mon, Feb 24, 2025 1:22 PM

Hi,
Can you give me the corrected c code for my application?

Thanks.

On 2025-02-24 08:17, Martin Braun wrote:

On Mon, Feb 24, 2025 at 10:42 AM kavinraj@atindriya.co.in wrote:

Hi,
I have written a c code for GPIO toggling in USRP B205mini-i
board.
The pin should be high for 1microseconds and low for 1milliseconds.
I
have given the c code to verify whether it is correct or not?

while(1)
{
uhd_usrp_get_time_now(usrp, mboard, &full_secs,
&frac_secs);
uhd_usrp_set_command_time(usrp, full_secs , frac_secs +
1e-6,
mboard);

This won't work, you need to set this in the future from "time now".

error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x01,
mask1,
mboard);
uhd_usrp_clear_command_time(usrp, 0);
uhd_usrp_get_time_now(usrp, mboard, &full_secs,
&frac_secs);
uhd_usrp_set_command_time(usrp, full_secs , frac_secs +
1e-3,
mboard);

Same here.

error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x00,
mask1,
mboard);
uhd_usrp_clear_command_time(usrp, 0);
}

Get the time "now" outside of the loop, and use that as a base
reference. When you've fixed that, I recommend you connect it to an
oscilloscope for verification.

--M


USRP-users mailing list -- usrp-users@lists.ettus.com
To unsubscribe send an email to usrp-users-leave@lists.ettus.com

Hi, Can you give me the corrected c code for my application? Thanks. On 2025-02-24 08:17, Martin Braun wrote: > On Mon, Feb 24, 2025 at 10:42 AM <kavinraj@atindriya.co.in> wrote: > >> Hi, >> I have written a c code for GPIO toggling in USRP B205mini-i >> board. >> The pin should be high for 1microseconds and low for 1milliseconds. >> I >> have given the c code to verify whether it is correct or not? >> >> while(1) >> { >> uhd_usrp_get_time_now(usrp, mboard, &full_secs, >> &frac_secs); >> uhd_usrp_set_command_time(usrp, full_secs , frac_secs + >> 1e-6, >> mboard); > > This won't work, you need to set this in the future from "time now". > >> error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x01, >> mask1, >> mboard); >> uhd_usrp_clear_command_time(usrp, 0); >> uhd_usrp_get_time_now(usrp, mboard, &full_secs, >> &frac_secs); >> uhd_usrp_set_command_time(usrp, full_secs , frac_secs + >> 1e-3, >> mboard); > > Same here. > >> error = uhd_usrp_set_gpio_attr(usrp, bank, "OUT", 0x00, >> mask1, >> mboard); >> uhd_usrp_clear_command_time(usrp, 0); >> } > > Get the time "now" outside of the loop, and use that as a base > reference. When you've fixed that, I recommend you connect it to an > oscilloscope for verification. > > --M > _______________________________________________ > USRP-users mailing list -- usrp-users@lists.ettus.com > To unsubscribe send an email to usrp-users-leave@lists.ettus.com