discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] Quesion on AUX ADC of AD9862


From: Su Jinzhao
Subject: [Discuss-gnuradio] Quesion on AUX ADC of AD9862
Date: Tue, 16 Jun 2009 21:15:34 +0800

Hi,
 
    I want to read RSSI value using analog AUX ADC, I think we can read RSSI through AUX_ADC_A1 pin of AD9862, I looked through the code of usrp_read_aux_adc in file
/root/gnuradio/gnuradio-3.1.3/usrp/host/lib/legacy/usrp_primes.cc,

bool
usrp_read_aux_adc (struct usb_dev_handle *udh, int slot,
                   int which_adc, int *value)
{
  *value = 0;
  int   which_codec;
  if (!slot_to_codec (slot, &which_codec))
    return false;
  if (!(0 <= which_codec && which_codec < 2)){
    fprintf (stderr, "usrp_read_aux_adc: invalid adc = %d\n", which_adc);
    return false;
  }
  unsigned char aux_adc_control =
     AUX_ADC_CTRL_REFSEL_A             // on chip reference
    | AUX_ADC_CTRL_REFSEL_B;            // on chip reference
  int   rd_reg = 26;    // base address of two regs to read for result
  // program the ADC mux bits
  if (tx_slot_p (slot))
    aux_adc_control |= AUX_ADC_CTRL_SELECT_A2 | AUX_ADC_CTRL_SELECT_B2;
  else {
    rd_reg += 2;
    aux_adc_control |= AUX_ADC_CTRL_SELECT_A1 | AUX_ADC_CTRL_SELECT_B1;
  }
  // I'm not sure if we can set the mux and issue a start conversion
  // in the same cycle, so let's do them one at a time.
  usrp_9862_write (udh, which_codec, 34, aux_adc_control);
  if (which_adc == 0)
    aux_adc_control |= AUX_ADC_CTRL_START_A;
  else {
    rd_reg += 4;
    aux_adc_control |= AUX_ADC_CTRL_START_B;
  }
  // start the conversion
  usrp_9862_write (udh, which_codec, 34, aux_adc_control);
  // read the 10-bit result back
  unsigned char v_lo = 0;
  unsigned char v_hi = 0;
  bool r = usrp_9862_read (udh, which_codec, rd_reg, &v_lo);
  r &= usrp_9862_read (udh, which_codec, rd_reg + 1, &v_hi);
  
  if (r)
    *value = ((v_hi << 2) | ((v_lo >> 6) & 0x3)) << 2;        // format as 12-bit
  return r;
}
 
my question is:
1.The AD 9862 specification says: "The AUX SPI can be enabled and configured by setting register AUX ADC CTRL. Setting register use pins high enables the AUX SPI port.", but in the above code AUX_ADC_CTRL_AUX_SPI was not set high( In my opinion, aux_adc_control should be added with | = AUX_ADC_CTRL_AUX_SPI because usrp_9862_write and usrp_9862_read all need SPI operation, so we should enable AUX API), Is this a mistype or another method ?
2.stefan.bruens in the list had said that the low 16 bits is the RSSI value, I want to know why did the above code combine the high and low 16-bit and format the data into 12-bit ? 
3. Even with the RSSI value (int type), what should I do to convert that value into dBm unit ?
 
        Thanks.
--
Su Jinzhao

--
Su Jinzhao

reply via email to

[Prev in Thread] Current Thread [Next in Thread]