[SOLVED] shiftOut function with HV5622

Has anyone been able to use shiftOut to send values to an HV5622 32 bit shift register? I had assumed that I could treat it the same way I would with 4x SN74HC595 chips but I can’t get it working. I’m using an ESP8266 running Arduino code and I’m doing level shifting with MOSFETs. Code and circuitry works if I sub in the SN74HC595.

Relevant code looks like this:

digitalWrite(LATCH, LOW);
shiftOut(SER, CLK, MSBFIRST, B00000000);
shiftOut(SER, CLK, MSBFIRST, B00000000);
shiftOut(SER, CLK, MSBFIRST, B00000000);
shiftOut(SER, CLK, MSBFIRST, B00000000);
digitalWrite(LATCH, HIGH);

Thanks

Can you provide a link to the datasheet for the HV5622, and also your schematic?

On the face of it, I reckon your code should work. the shiftOut function is just this:

void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
{
	uint8_t i;

	for (i = 0; i < 8; i++)  {
		if (bitOrder == LSBFIRST)
			digitalWrite(dataPin, !!(val & (1 << i)));
		else	
			digitalWrite(dataPin, !!(val & (1 << (7 - i))));
			
		digitalWrite(clockPin, HIGH);
		digitalWrite(clockPin, LOW);		
	}
}

So, even though the HV5622 clocks on the falling edge and the '595 on the rising edge, it shouldn’t actually matter.

If you are using the SER and CLK pins for other things as well, you need to write LATCH low again to maintain the data in the HV6522:

     "Transfer of data from the Shift register to the latch occurs when the LE input is high. 
      The data in the latch is stored when LE is low"

so just add digitalWrite(LATCH, LOW); on the end of your code snippet.

Have you got pullups on the HC5622 outputs ?
They are open-drain…

Yours,
TonyWilk

Turns out that this is a hardware issue. My level shifter circuit couldn’t shift the level high enough. If I reduced the input voltage to <= 8 volts, the code works as-is.