Texas Instrument Binary Counter SN74LV8154 - it has the occasional error

Hi,
I am using the binary counter SN74LV8154 (https://www.ti.com/product/SN74LV8154) to count pulses from a water flow meter (hall effect). In testing the chip prior to integrating with the flow meter, I picked up an error. I was hoping someone on this forum may be able to assist.

I have the chip wired to a Rasperry Pi (3B+) to simulate the high frequencies required. I have been loading the counter using different period square waves, and have the chip daisy chained to count up to 2**32. It all works well, counting consistently even very short (nano second) pulses. I am confident that my software is correct, and my hardware is correctly wired, as the vast majority of counts I feed the counter, are returned correctly when I interrogate via the 4 x 8 bit bus calls.

However once it gets beyond 65,536 (216), and start getting into the second register of the counter , if I load the counter with a number of signals which results in the 8 pins of the lowest register (GAL pin) being all 1's, all of a sudden I get unpredictable results. Examples:
2
23 counts perfectly
(223) - 1: returns the incorrect count
2
22: counts perfectly
(222) - 1: returns the incorrect count
(2
22) - 3: counts perfectly
(2**22) - 7: counts perfectly

I have varied signal pulse frequencies and periods from a nonosecond, up to a full second without altering the results. I have also tried installing physical pullup and pulldown resistors (beyond the Pi software configured pullup/down functionality) on all the counters pins without changing the results.

Does anyone know what the problem could be, what else I could try?

Are your incorrect results repeatable? What counts do you get for the errors?

There's something fishy here. It's as if it can count to 10 correctly, but gives the wrong result for 9. Do you have access to another counter that you could use to confirm the Pi output? What happens if you count to (2**23)-1, read it, then give it one more pulse?

I’m also curious about a water flow meter that generates signals with around a 1ns period, which is in the 1GHz range. Have you a link to it ?

Also include your code for generating the pulses reading the registers of this counter chip.

If, for example, you use a test frequency of 16Mhz, the 16 bit counter will wrap around every 4ms, the full 32 bit counter wii wrap around every 4 minutes or so.

How are you going to use the counter chip in practice? Are you going to periodically reset it, wait a fixed period, then sample the results? If so, what sampling period?

I have the chip wired to a Rasperry Pi (3B+) to simulate the high frequencies required.

What is the max frequency?
Is this the DIP-20 version on a breadboard?
Do you have a bypass capacitor 0.01-μF to 0.022-μF close to the VCC and GND pins?
Are wire lengths short?

The fault is hard to determine if you don't provide a full schematic of your circuit.

This chip definitely won't handle pulses of length 1ns as its a standard LVCMOS family logic chip
which tend to only support ~40--50MHz or so for max clock. It requires a minimum pulse width of 10ns at
5V supply, and even more at 3.3V (I presume you run it at 3.3V if connected to a RPi??)

My suspicion is you've omitted decoupling for this chip. No logic chip is guaranteed to work
without decoupling, all bets are off, and almost any strange behaviour could show up if you
omit decoupling or have very poor layout between the chip and the decoupling cap(s).

100nF from Vcc to ground for every supply pin, close to the pin, is standard for logic chips like this.

I've used this chip in a frequency counter without seeing any issues, its very handy for such
tasks.

Very strange, I already used a water flow meter with a hall sensor, YF-S201, but there is no need to simulate high frequency to test this. I used a simple Arduino UNO (Pro mini) with the interrupt input on pin 2, it was enough.

The the maximum is 90 Hz: