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).
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.
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
>