Programming HV2801

Hi everyone,

This is my first post so sorry if I don't give all the information you need. Be free to ask anything you need.

I am using Arduino to control a 32 channel mux, the HV2801. I have read the other two posts in this forum about this IC, but I have a problem. I'm trying to control two of these ICs, but the Latch Enable is not working. Both of the ICs activate the same switches, so I can't activate the switch 1 in one IC and the switch 2 in the other IC.

Here is the code I am using:

#include <SPI.h>

const int CLR1=7;
const int LE1 =2;
const int CLR2= 8;
const int LE2 =4;
const int DIN =11; // Data in logic input
const int CLK =13; // Clock logic input for Shift register 

void setup() {
  
  pinMode(LE1, OUTPUT);
  pinMode(CLR1, OUTPUT);
  digitalWrite(CLR1, HIGH);
  
  pinMode(LE2, OUTPUT);
  pinMode(CLR2, OUTPUT);
  digitalWrite(CLR2, HIGH);

  delay(100);
  
  digitalWrite(CLR1, LOW);
  digitalWrite(CLR2, LOW);

  digitalWrite(LE1, HIGH); 
  digitalWrite(LE2, HIGH);
  
  delay(100);   

  SPI.begin();
  SPI.setBitOrder(MSBFIRST); 
  SPI.setDataMode(SPI_MODE3);
   
  delay(100);
  SPI.transfer(B10000000); 
  SPI.transfer(B00000000); 
  SPI.transfer(B00000000); 
  SPI.transfer(B00000000);
  delay(100);
  digitalWrite(LE1, LOW);
  delay(100);
  digitalWrite(LE1, HIGH);
  delay(100);

  SPI.transfer(B00000000); 
  SPI.transfer(B00000000); 
  SPI.transfer(B00000000); 
  SPI.transfer(B00000001);
  delay(100);
  digitalWrite(LE2, LOW);
  delay(100);
  digitalWrite(LE2, HIGH);
  delay(100);
}
void loop() {
}

Here I want the first IC to turn on the first switch and the second IC to turn on the last switch, but both of them activate the last switch. They just do the last information sent.

The datasheet of the chip: https://www.mouser.es/datasheet/2/268/MCHP_S_A0008607656_1-2521038.pdf

Thank you.

are the 2 ICs daisy chained or wired up in parallel?

They are wired up in parallel and each DIN is connected to the MOSI pin in the Arduino.

try connecting the DOUT of the first IC to the DIN on the second IC, then send all the transfer bytes successively before you finally toggle the LE's.

hope that helps...

But DOUT is HIGH only when data in register 31 is HIGH. Anyway, I have the ICs soldered to a PCB and it has no pin for DOUT. I tried letting LE always be HIGH so the IC wouldn't change its state, but it does anyway.

Hi, @idonat
Welcome to the forum.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

This is the schematic of the two ICs:


Vdd is set to 5 V, Vpp to +25 V and Vnn to -25 V. DIN and CLK are used with the SPI protocol. I1, I2, GND1 and GN2 are the signals I want to switch.

I have another PCB with only one IC and it doesn't listen to the LE pin. It simply do the last thing I send.

Hi.
Can you please post a basic schematic showing how you have got the 2801s connected to your controller?

What model Arduino are you using?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

The connections are:

MOSI (11) --- DIN
SCK (13) --- CLK
Pin 2 --- LE1
Pin 4 --- LE2
Pin 7 --- CLR1
Pin 8 --- CLR2

Here is a scheme:

I'm using an Arduino UNO and the SPI protocol. The strange thing is that the switches activate correctly, but they just do the same thing.

Thanks for the help.

It only takes a 12ns pulse to activate LE.
I suspect that you have some coupling between LE1 and LE2 on your PCB and when you activate one it causes a glitch on the other.

You can test my hypothesis by holding CLR HIGH on IC2 while writing data to IC1 and vise versa and see if the correct data is being sent to the selected IC

So it worked, I don't know why but it works. I tried what jim-p said and it did what he said, and when I tried the original code again it worked.

I have to say that when I take some measures with the multimeter, the IC bugs and does the same I've been talking about. But I restart the Arduino and it works.

Anyway, thank you so much for the help.