On 12/28/2012 08:24 PM, Ryan Monroe wrote:
Hey Tom, remember that the gain setting on the katadc block was not
enabled on that design. You'll probably need that to control adc gain
I'd forgotten that you told me that, Ryan, but now that you remind me I
also recall thinking that since the iic_adc0 register is in the design,
there must be a way of talking to the KATADC. That appeared to be the
case, until I cycled power. Mason's explanation seems to say that there
is some other thing that I can do via that register to enable attenuator
control after power-up.
On 12/28/2012 10:03 PM, Jason Manley wrote:
If you take a look at the KATADC yellow block, you'll see there's an input port for configuring
it from the simulink gateware. In this spectrometer design, that port is tied to a software
register called "adc_ctrl0". It has 6 bits (lsbs) to set the attenuator in half-db
steps and the msb toggles the termination switch. So that's what
self.fpga.write_int('adc_ctrl0',(1<< 31) + int((20-gain)*2)) is doing. This was done to
remain compatible with the iadc design of the same spectrometer, where we use external
minicircuits attenuators and switches and control them using the same software register (from
which the FPGA serialises this on GPIO pins).
Thanks. That's what I suspected from the
if self.adc_type == 'katadc':
...
elif self.adc_type == 'iadc':
...
test in spec.rf_gain_set() since the IADC doesn't have an RF stage. I
thought that maybe there was something KATADC-specific elsewhere in the
code.
The ADC will retain this setting (even with FPGA reprogramming) unless it is
explicitly reconfigured from software or by the FPGA's onboard controller or is
reset by power cycling. By default, such a controller is compiled-in when you
compile for the KATADC.
I am out of the office, but will happily check the I2C controller when I get
back in January. I last checked this on ROACH-1 in ~2011 and don't think it's
ever been tested on ROACH-2. Perhaps something's gone awry with the base
packages.
Well, we are using ROACH-1s and I should have made that explicit.
Apologies. I guess, pending a resolution of this issue, I can try a
work-around in which I first load KAT_rfi_sys and then replace it with
kurtspec. Not elegant but ...
Thanks and Happy New Year to all
Tom
Jason
On 29 Dec 2012, at 05:03, Tom Kuiper wrote:
I have two designs I'm playing with. I find that if I run the KAT_rfi_sys 16K
spectrometer, then after that I can control the RF attenuators with
corr.katadc.rf_fe_set(). However, if I load another design developed here
(kurtspec) into a cold ROACH (i.e. after power cycling) corr.katadc.rf_fe_set()
doesn't work.
corr.katadc.rf_fe_set() uses corr.katadc.iic_write_register() like this:
iic_write_register(fpga, katadc_n, 0x20+pol, 2,
0x40+(enabled<<7)+int((gain*2)+23))
and this iic_write_register() does a series of FPGA register writes:
iic_controller='iic_adc%i' % katadc_n
fpga.blindwrite(iic_controller, '%c%c%c%c' % (0x0,0x00,0x00,0x01), offset=12)
fpga.blindwrite(iic_controller, '%c%c%c%c' % (0x0,0x00, WR | START | LOCK,
(dev_addr<< 1) | IIC_WR), offset=0x0)
fpga.blindwrite(iic_controller, '%c%c%c%c' % (0x0,0x00, WR | LOCK, reg_addr),
offset=0x0)
fpga.blindwrite(iic_controller, '%c%c%c%c' % (0x0,0x00, WR | STOP, reg_value),
offset=0x0)
fpga.blindwrite(iic_controller, struct.pack('>4B',0,0,0,0), offset=12)
That is, it writes to register 'iic_adc0'.
However, I noticed that the KAT_rfi_sys 16K spectrometer initialization script,
which optimizes the attenuator, actually writes to directly to another FPGA
register like this:
self.fpga.write_int('adc_ctrl0',(1<< 31) + int((20-gain)*2))
This makes me think that there is something else going on in the 16K
spectrometer design that enables gain control and that this stays that way in
the hardware even when anotherfirmware design is loaded.
Does anyone have any idea about what's going on here?
Thanks and best wishes for the New Year.
Tom