Using SPI on BasicRX

Hello.
I’m trying to use the SPI interface of a BasicRX.
I made a small test program.
It basically keeps on writing.

There are a few things I need to know:
1 - is this the right way to use the SPI?
2 - is the buffer the hex number passed as a string?
3 - Even though I don’t know what to expect with the buffer I used, I at
least expected to see something in the BasicRX SPI pins, which I
don’t… I
can see some periodic bursts on the clock pin but nothing on the signal.

Thanks in advance for any help you can give me.

The code I’m using is the one below:

from gnuradio import gr
from gnuradio import window
from gnuradio import usrp, howto
import wx
import time
from gnuradio import audio

class FlowGraph(gr.top_block):
def init(self):
gr.top_block.init(self)

decimation = 256
center_frequency = 10.7e6

self.u = usrp.source_c(0, decimation, 

fpga_filename=“std_2rxhb_2tx.rbf”)
self.u.set_nchannels(1)
self.subdev_spec = (0,0)
self.subdev = usrp.selected_subdev(self.u, self.subdev_spec)
self.subdev.set_auto_tr(True)
self.subdev.select_rx_antenna(‘RX2’)
self.u.tune(0, self.subdev, center_frequency)
g = self.subdev.gain_range()
gain = float(g[0]+g[1])/2
self.subdev.set_gain(gain)

if name == “main”:
print “Creating flowgraph…” ,
tb = TunerFlowGraph()
print “[DONE]”

print "Starting flowgraph...",
tb.start()
print "[DONE]"

while(1):
print "Writing to SPI...",
usrp.sink_s()._write_spi(0, usrp.SPI_ENABLE_RX_A,

usrp.SPI_FMT_HDR_0|usrp.SPI_FMT_LSB, “@”)
time.sleep(.030)
print “[DONE]”

View this message in context:
http://www.nabble.com/Using-SPI-on-BasicRX-tp25440578p25440578.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On Mon, Sep 14, 2009 at 11:02:36AM -0700, E. Ornelas wrote:

Hello.
I’m trying to use the SPI interface of a BasicRX.
I made a small test program.
It basically keeps on writing.

There are a few things I need to know:
1 - is this the right way to use the SPI?

Pretty close. See below.

2 - is the buffer the hex number passed as a string?

It’s binary, not hex.

3 - Even though I don’t know what to expect with the buffer I used, I at
least expected to see something in the BasicRX SPI pins, which I don’t… I
can see some periodic bursts on the clock pin but nothing on the signal.

We never implemented SPI_FMT_LSB; Use SPI_FMT_MSB instead.

Try this:

from gnuradio import usrp

u = usrp.source_c(0)
spi_cmd = ‘’.join([chr(x) for x in [0x55, 0xAA, 0x55, 0xAA]])

while True:
r = u._write_spi(0, usrp.SPI_ENABLE_RX_A,
usrp.SPI_FMT_HDR_0|usrp.SPI_FMT_MSB, spi_cmd)

Look at the SDI (into the d’board), SCLK and SEN pins.

Eric

On Tue, Sep 15, 2009 at 09:06:58AM -0700, E. Ornelas wrote:

Thanks for the help.

I have another question:
I noticed that the transfer is done 8-bit at a time.
I need to write a 24-bit word into a ADF4153 Frequency Synthesizer.
Is it possible to transfer 24-bit in a single burst?

The example below writes 32 bits in a single transfer.
You can confirm this by looking at the SEN and CLK signals.

To send 24-bits, give it 3 bytes.

Eric

Thanks for the help.

I have another question:
I noticed that the transfer is done 8-bit at a time.
I need to write a 24-bit word into a ADF4153 Frequency Synthesizer.
Is it possible to transfer 24-bit in a single burst?

Again, thank you for your time.

Eric B. wrote:

while True:

self.subdev_spec = (0,0)
tb = TunerFlowGraph()
time.sleep(.030)
print "[DONE]"

Discuss-gnuradio mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


View this message in context:
http://www.nabble.com/Using-SPI-on-BasicRX-tp25440578p25456853.html
Sent from the GnuRadio mailing list archive at Nabble.com.

Hi.
Just to say I got it to work as I wished.
As always, thanks for the help Eric.

Eric B. wrote:

The example below writes 32 bits in a single transfer.

Eric B. wrote:

I
u = usrp.source_c(0)
Eric


Discuss-gnuradio mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


View this message in context:
http://www.nabble.com/Using-SPI-on-BasicRX-tp25440578p25530780.html
Sent from the GnuRadio mailing list archive at Nabble.com.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs