USRP2 write_gpio() command

I’m trying to use one of the GPIO pins on my USRP 2 / WBX daughtercard
to control an external antenna selector box. I’ve created a simple GUI
with a USRP2 source feeding into a graphical FFT sink, and I’m able to
change the state of io_tx_14 using the following code:

#this code is called when the program is started
self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex*1)
self.howto_rx_gpio_0 = usrp2.source_32fc()
self.howto_rx_gpio_0.set_decim(decimation)
self.howto_rx_gpio_0.set_center_freq(frequency)
self.howto_rx_gpio_0.set_gain(daughtercard_gain)
self.howto_rx_gpio_0.set_gpio_ddr(0xffff, 0b0100000000000000) #set the
DDR
self.howto_rx_gpio_0.set_gpio_sels(".s…") #set the output
selection register

#this code is called when the checkbox on the GUI is changed
def set_check(self, check):
self.check = check
self._check_check_box.set_value(self.check)
self.howto_rx_gpio_0.write_gpio(self.check * 2**14, 0xffff)

The problem is that whenever I change the value of the checkbox, the FFT
sink freezes and stops displaying new values, or it begins displaying
garbage at like -300 dB. The pin continues to change from high to low
just fine even after the FFT sink stops updating. I’ve tried restarting
the source using the stop() and start() commands, but this does not
help. The problem is not unique to the FFT sink - applying the same code
to a working NBFM receiver causes the audio sink to start playing
popping sounds. I considered using gr-gpio, but this requires custom
firmware, and I’m already running custom firmware to support my WBX
daughtercard. Does anyone have any ideas?

– Ryan

On Mon, Jul 19, 2010 at 12:18:06PM -0600, Ryan L. Buffington wrote:

#this code is called when the checkbox on the GUI is changed
def set_check(self, check):
self.check = check
self._check_check_box.set_value(self.check)
self.howto_rx_gpio_0.write_gpio(self.check * 2**14, 0xffff)

The above line sets the value of 16-bits, most likely screwing up the
daughterboard configuration.

You most likely want something like:

self.howto_rx_gpio_0.write_gpio(self.check * 2**14, 1 << 14)

Note, I haven’t looked to see if bit 14 is a valid user bit on the
daughterboard you’re using. You should :slight_smile:

The problem is that whenever I change the value of the checkbox, the
FFT sink freezes and stops displaying new values, or it begins
displaying garbage at like -300 dB. The pin continues to change from
high to low just fine even after the FFT sink stops updating. I’ve
tried restarting the source using the stop() and start() commands,
but this does not help. The problem is not unique to the FFT sink -
applying the same code to a working NBFM receiver causes the audio
sink to start playing popping sounds. I considered using gr-gpio,
but this requires custom firmware, and I’m already running custom
firmware to support my WBX daughtercard. Does anyone have any ideas?

– Ryan

Eric