Shift Register Question: Rising and Falling Clock Pins

I have completed Example 1 of this tutorial:

https://www.arduino.cc/en/Tutorial/ShiftIn

and I have some questions about shift registers and the arduino's shiftIn function.

This is my shift register:

http://www.digikey.com/product-search/en?keywords=296-2040-5-nd http://www.ti.com/lit/ds/symlink/cd4014b.pdf (product datasheet)

The tutorial code uses a custom shiftIn function instead of the shiftIn function that is a part of the Arduino language:

https://www.arduino.cc/en/Reference/ShiftIn

I wanted to understand why so I modified the tutorial code to call the other function:

switchVar1 = shiftIn(dataPin, clockPin, MSBFIRST);

Much to my surprise, the circuit no longer worked correctly. For most of the buttons the bits were shifted over one.

I found the source code to Arduino's shiftIn function here:

https://forum.arduino.cc/index.php?topic=391376.0

After doing some experimenting, I found I had to invert the writes to the clockPin, flipping HIGH and LOW. Then it worked.

I believe this has something to do with the shift register doing the serial shifting on either the rising and falling clock edges. Arduino's shiftIn function expects it to be done one way, but this shift register does it the other way. That's why it was necessary for the tutorial to use a custom shiftIn function.

I have some questions.

The Arduino documentation says:

If you're interfacing with a device that's clocked by rising edges, you'll need to make sure that the clock pin is low before the first call to shiftIn(), e.g. with a call to digitalWrite(clockPin, LOW).

I tried doing that but I still couldn't get it to work correctly using the built-in shiftIn function. Is it possible to do that, or am I misunderstanding something?

Where in the product datasheet does it tell me that this won't work with the built-in shiftIn function? What is the proper terminology to describe this?

The tutorial includes a delay after setting the clockPin low.

delayMicroseconds(0.2);

Taking that out didn't do anything. Is it necessary? Does it have something to do with the Clock Risk and Fall Time, as documented on the second page of the datasheet?

And what else can I do to learn more about shift registers here?

Thank you!

Where in the product datasheet does it tell me that this won't work with the built-in shiftIn function?

You will not find any reference to an Arduino in any chip's data sheet, especially as the chip pre dates the Arduino by at least 30 years. In the data sheet, the writing in the first column on the first page says data is clocked in on the positive transition of the clock.

The parameter that you are exceeding is the data set up time, the shift out function is not waiting long enough after the changing the output to the serial input of the chip before clocking the clock pin.

This might be a silly question but do you know how to read a datasheet ? You DID NOT cite any datasheet parameters so it begs the question: Did you or did you not read the darasheet for the CD4014 chip you are using ? EDIT: I see Mike already answered that question. No and no. So what's my point ? You should look at the datasheet and post for each or all of the parameters you do NOT understand BEFORE attempting to ever run the curcuit. This newbie propensity for "I will try my circuit FIRST BEFORE attempting to learn anything about the chip parameters " only wates your time and our time. A parameter called "setup time" might seem relavant at first glance.

And what else can I do to learn more about shift registers here?

That's a good question. What I would suggest is that when you first decide to use a chip to take a black sheet of printer paper, print out the datasheet for the chip , and write down the most important parameters and their values so you can refer to it when coding.

Was the original post changed? Link to the part at Digikey and the TI datasheet are there.

Was the original post changed? Link to the part at Digikey and the TI datasheet are there.

Yes , I changed it when I realized it was there.

delayMicroseconds(0.2);

Is that even valid? I thought the lowest delayMicroseconds could do is 3-4uS.

Is that even valid? I thought the lowest delayMicroseconds could do is 3-4uS.

Caveats and Known Issues

This function works very accurately in the range 3 microseconds and up. We cannot assure that delayMicroseconds will perform precisely for smaller delay-times.