Local Oscillator Computed I and Q Table

The LO Computed I and Q table is a table of the computed I and Q values (LO Control Values) associated with the attenuation settings of the device. The I and Q values are kept for each possible attenuation value and are indexed by RF Attenuation and Baseband Attenuation. If the PAD Mixer is enabled, the value is considered different from the attenuation setting without the PAD Mixer and are stored as such. Additionally, entries may be marked as used or unused to help speed up calibration when the table isn't empty.

Building the Table

There are specific branches in the sections below that depend upon whether the table is empty or not. On init and after certain events, the table is cleared and then rebuilt.

Start

In this phase, registers are backed up and the LO is put into a known frequency to prepare for calibration.

  1. If Hardware Power Control is enabled

    1. Backup PHY Registers 0x80F, 0x801, 0x60, 0x14, 0x478

    2. OR PHY Register 0x478 with 0x100

    3. OR PHY Register 0x801 with 0x40

    4. OR PHY Register 0x60 with 0x40

    5. OR PHY Register 0x14 with 0x200

  2. If this isn't a GPHY
    1. Return /!\ Note older versions had B PHY Code too...

  3. If the table isn't empty and Hardware Power Control is enabled

    1. Read in the Power Vector from SHM offset 0x310 in 16 bit pieces, but clear the top 8 bits of each 16 bit value (Note that this introduces 8 bits of 0 between 8 bits of data read)

    2. Clear the Power Vector at SHM offset 0x310 by writing 0's

    3. If any Power Vector bits are set

      1. Save a copy of the Power Vector

    4. Loop from 0 to 0x40
      1. If the saved Power Vector has the bit corresponding to this loop position set

        1. The RF Attenuation value corresponding to this position is found by dividing the list position by the length of the RF Attenuation List for this board and throwing away the remainder, this is the offset to use in the RF Attenuation List

        2. The Baseband Attenuation value corresponding to this position is found by dividing the list position by the length of the RF Attenuation Values for this board and only keeping the remainder, this is the offset to use in the Baseband Attenuation List

        3. Mark as used the I and Q table entry corresponding to the Baseband and RF attenuation values found above
  4. If the PHY Revision is 2 or greater
    1. Save PHY Registers 0x814, 0x815, 0x811, 0x812, 0x802, 0x3E, 0x429

    2. AND PHY Register 0x802 with 0xFFFC

    3. AND PHY Register 0x429 with 0x7FFF

    4. OR PHY Register 0x814 with 3

    5. AND PHY Register 0x815 with 0xFFFC

    6. If PHY Revision is 7 or greater and the Board Flags indicate an External LNA

      1. Write 0x933 to PHY Register 0x811

    7. Otherwise
      1. Write 0x133 to PHY Register 0x811

    8. Write 0 to PHY Register 0x3E

  5. Back up Core Registers 0x3F4, 0x3E2

  6. Back up Radio Registers 0x43, 0x7A

  7. Back up PHY Registers 0x15, 0x2A, 0x35, 0x60

  8. If TX Magnification isn't enabled

    1. Back up Radio Register 0x52

    2. AND the backed up value with 0xF0
  9. Back up the current channel
  10. OR Core Register 0x3E2 with 0x8000

  11. AND Core Register 0x3F4 with 0xF000

  12. Write 0x7F to PHY Register 0x80F

  13. Write the backed up value of PHY Register 0x35 AND'd with 0xFF7F to PHY Register 0x35

  14. Write the backed up value of Radio Register 0x7A AND'd with 0xFFF0 to Radio Register 0x7A

  15. Write 0x8A3 to PHY Register 0x2A

  16. Write 0x1003 to PHY Register 0x2B

  17. If the PHY Revision is 2 or greater
    1. Perform a CCK Dummy Transmission

  18. Set the channel to 6
  19. Perform a dummy read on Radio Register 0x51

  20. If this is a G PHY
    1. Write 0 to PHY Register 0x2F

  21. If the table is empty
    1. If Loopback Gain is disabled

      1. The Loopback Gain value is 0

      2. The TRSW_RX value is 2

      3. The PGA value is 0

      4. MaskSet the Power Control Radio Register (0x43) with mask 0xFFF0 and set with 6

    2. Otherwise, the values must be computed
      1. The TRSW_RX value is 0

      2. Take the saved Maximum Loopback Gain value and divide the result by 2, this is the Loopback Gain value (converted back to dB from hdB)

      3. If the Loopback Gain value in hdB is greater than 10

        1. Subtract 10 from the Loopback Gain value in hdB, then divide that by 6, this is the PGA Value

        2. If the PGA Value is 0x10 or greater

          1. Use 0xF as the PGA Value instead

        3. MaskSet the Power Control Radio Register (0x43) with mask 0xFFF0 and set with 0

      4. Otherwise
        1. The PGA value is 0

        2. If the PHY Revision is 2 or greater with a 0x2050 radio with revision 8
          1. The Loopback Gain Comparison value is 0xF
        3. Otherwise
          1. The Loopback Gain Comparison value is 0x9
        4. If the Loopback Gain in hdB is less than the Loopback Gain Comparison value multiplied by 4
          1. The Power Control value starts with the Loopback Gain Comparison value multiplied by 4
        5. Otherwise
          1. The Power Control value starts with the Loopback Gain value in dB
        6. If the Loopback Gain value in hdB is less than 0
          1. Add 6 to the Power Control value
        7. Otherwise
          1. Add 3 to the Power Control value
        8. Divide the Power Control value by 4
        9. If the Power Control value is less than the Loopback Gain Comparison value