pe4302

huy guys,
i have a question about pe4302 breakout board
picture of pe4302 breakout board:


pe4302 datasheet:
http://www.psemi.com/pdf/datasheets/pe4302ds.pdf
at page 6 in table 6 "Parallel PUP Truth Table"
Table 6 states that if the latch is enabled then the attenuation is determined by C0.5-C16

and i dont understand two things
what is the switches in the breakout board?
(i want to determine the attenuation only by arduino software)
And second thing is about code i found
i think the code is the answer for the first question but i'm not sure I've got it right
i want to know if this code is fine and i can use it to control the attenuation with this code?
this is the code:

int LE = 2;
int CLOCK = 3;
int DATA = 4;

// The setup routine runs once when you press reset.
void setup() {

  //Serial.begin(9600);

  // Initialize pin as outputs.
  pinMode(LE, OUTPUT);
  pinMode(CLOCK, OUTPUT);
  pinMode(DATA, OUTPUT);
}

// The loop routine runs over and over again forever.
void loop()
{
  int value;   // Attenuation value, 0 through 31.
  int ms = 1000; // How log to pause before next value (in msec)

  // Step though each attenuation level pausing for 1 second at each
  // value.
  for (value = 0; value <= 31; value++) {
    //Serial.print(value); Serial.println(" dB");
    setAttenuator(value);
    delay(ms); // wait for a second before repeating
  }

  for (value = 31; value >= 0; value--) {
    //Serial.print(value); Serial.println(" dB");
    setAttenuator(value);
    delay(ms); // wait for a second before repeating
  }
}

/*
  Set attenuation level of PE4306 Digital Step Attenuator in serial
  mode. Level is in range 0 to 31 dB. Do not call this at a rate
  faster than 25 KHz (every 0.05 msec). Should work with other PE430x
  series chips with minor changes. The code runs slowly enough that
  we do not need to add any delays.
*/

void setAttenuator(int value)
{
  int level; // Holds level of DATA line when shifting
  
  // Check for value range of input.
  if (value < 0 || value > 31)
    return;

  // Initial state
  digitalWrite(LE, LOW);
  digitalWrite(CLOCK,LOW);
  
  for (int bit = 5; bit >= 0; bit--) {
    if (bit == 0) {
      level = 0; // LSB is always zero
    } else {
      level = ((value << 1) >> bit) & 0x01; // Level is value of bit
    }

    digitalWrite(DATA, level); // Write data value
    digitalWrite(CLOCK, HIGH); // Toggle clock high and then low
    digitalWrite(CLOCK, LOW);
  }

  digitalWrite(LE, HIGH); // Toggle LE high to enable latch
  digitalWrite(LE, LOW);  // and then low again to hold it.
}

(this code is for PE4306 the Difference is PE4302 has 6bit and PE4306 has 5bit)

thanks in advance

You need to set the P/S bit to 1 for serial control - its controlled by one of the switches, as
apparently is LE (maybe by a weak pullup?, that's brought out too). I suspect you just have to
try 4 combinations of those two switches and see which one allows correct serial programming with
the latch operating correctly.

MarkT:
You need to set the P/S bit to 1 for serial control - its controlled by one of the switches, as
apparently is LE (maybe by a weak pullup?, that's brought out too). I suspect you just have to
try 4 combinations of those two switches and see which one allows correct serial programming with
the latch operating correctly.

you mean to the pullup switchs?

avibd:
you mean to the pullup switchs?

My mistake did not get you right But now yes

There is a small problem i dint have the attenuator yet so i can not deal with switches there and check so I'm currently trying to do a kind of simulation by the monitor So I check the code I found earlier

It might be worth tracing the pcb when you get it to see if there are any pull-ups or pul-downs on
some of the lines and so forth...