Writing To An IO FPGA Register

I am trying to write to an IO register on my FPGA to open the lines of
communication. Right now I am just using benchmark_tx.py as my test
case.

In transmit_path.py I added the following

self.u._write_fpga_reg(usrp.FR_OE_1,4227922944)
self.u._write_fpga_reg(usrp.FR_IO_1,4227922944)

I based this off of code I saw in other places, however I am getting
an error. My error is below:

Traceback (most recent call last):
File “./benchmark_tx.py”, line 138, in
main()
File “./benchmark_tx.py”, line 102, in main
tb = my_top_block(mods[options.modulation], options)
File “./benchmark_tx.py”, line 42, in init
self.txpath = transmit_path(modulator, options)
File
“/home/ben/Desktop/gnuradio/gnuradio-examples/python/digital/transmit_path.py”,
line 68, in init
self._setup_usrp_sink()
File
“/home/ben/Desktop/gnuradio/gnuradio-examples/python/digital/transmit_path.py”,
line 119, in _setup_usrp_sink
self.u._write_fpga_reg(usrp.FR_OE_1,4227922944)
File
“/usr/local/lib/python2.5/site-packages/gnuradio/usrp/usrp_swig.py”,
line 2254, in _write_fpga_reg
return _usrp_swig.usrp_sink_c_sptr__write_fpga_reg(*args, **kwargs)
TypeError: in method ‘usrp_sink_c_sptr__write_fpga_reg’, argument 3 of
type ‘int’

Any help with this would be appreciated.

Also, I am new to Python. Is 0xFC00FC00 also correct for the register
value?


Benjamin Perry
Georgia Tech, Undergraduate Computer Engineering
Vice President Scuba Tech
CS1371 TA
518.578.6207

On Mon, Feb 09, 2009 at 01:06:36AM -0500, Ben P. wrote:

an error. My error is below:
self._setup_usrp_sink()

Also, I am new to Python. Is 0xFC00FC00 also correct for the register value?

Uhh, why are you trying to directly write these particular low-level
registers? There’s a high-level interface to write these.
Take a look at usrp_basic.h (and while you’re at it, usrp_standard.h).

Independent of that, your problem is that 4227922944 is too big to fit
in a signed int. Try gru.hexint(0xfc00fc00).

So I am using higher-level interfaces to write to these registers.
Namely I am concerned with writing to the output enable register for
RxA. From my understanding of what I have to do I set up my source_c
and then I am able to write_oe/io with a value to either 0 for a? and
1 for b?. My code is below:

result = u._read_fpga_reg(usrp.FR_OE_1)
print result
result = (result | 0xFC<<8)
print u._write_oe(0,result,result)
print u._read_fpga_reg(usrp.FR_OE_1)

This is for an RFX2400 d’board so I should have access to the 8-topmost
bits.

When I read the initial value in FR_OE_1 (RxA) I get 31 and after I
write the desired write_oe and read it back I get 32. All return
values are obviously in decimal. Any help would be appreciated.

Ben

On Mon, Feb 9, 2009 at 10:53 AM, Eric B. [email protected] wrote:

I based this off of code I saw in other places, however I am getting
line 68, in init
Any help with this would be appreciated.


Benjamin Perry
Georgia Tech, Undergraduate Computer Engineering
Vice President Scuba Tech
CS1371 TA
518.578.6207

On Mon, Feb 09, 2009 at 09:56:43PM -0500, Ben P. wrote:

print u._read_fpga_reg(usrp.FR_OE_1)

This is for an RFX2400 d’board so I should have access to the 8-topmost bits.

When I read the initial value in FR_OE_1 (RxA) I get 31 and after I
write the desired write_oe and read it back I get 32. All return
values are obviously in decimal. Any help would be appreciated.

Virtually none of the FPGA registers may be read back. In fact, none
of the ones that you can write can be read, thus your test is
ill-founded.

You are correct about 0 of A, 1 for B.

Try this for side A:

u._write_oe(0, 0xfc00, 0xfc00)
i = 0
while 1:
u.write_io(0, i << 12, 0xfc00)
i = (i + 1) & 0xff

and look at the pins with an oscope.

Eric