Programming a serial clock?


I am looking at using the 74HCT164 in a future project and I was curious as to how I would have it use a clock? A lot of its serial input is entered in when the clock is on its rising edge. I've always used chips that have examples for them, and they took care of the clock in the programming with an external library. Now that i'm coming up with my own program, I figure I need to know how to do that. How would I make the arduino constantly send a square wave clock?

Are you planning to send serial data from the Arduino to this chip? If so, can generate the clock all with the data. You set the data pin to the desired value, set the clock pin high for a small amount of time and then set it low again.

Don't confuse the meaning of clock in this case. "Clock" means to "clock in" the data. So you only generate the clock when the data is valid. It doesn't run continuously.

Hm interesting. After looking over its datasheet, it seems extremely similar to the 74HC595. Why are there two seperate chips? They are both 8-bit serial in and parallel out chips.

Different features.

595 has parallel or serial out and has tristated inputs.

164 only has parallel out.

Since I’m already amplifier with the 595, could I just use that to achieve the same results?

That sentence doesn't make sense. What results? What amplifier?

oh haha, wow I don't know how amplifier got in there, I meant familiar.

The '595 has an output register clock, so you can daisy chain several and have all outputs change at once using the output register clock, often referrred to as Latchpin in sketches. The '164 does not have an output register, so the outputs start changing as soon as you start clocking data in.

Up to you to decide if that's acceptable.

funkyguy4000: How would I make the arduino constantly send a square wave clock?

const byte LED = 9;

void setup() {
  pinMode (LED, OUTPUT);
  // set up Timer 1
  TCCR1A = _BV (COM1A0);  // toggle OC1A on Compare Match
  TCCR1B = _BV(WGM12) | _BV(CS10) | _BV (CS12);   // CTC, scale to clock / 1024
  OCR1A =  4999;       // compare A register value (5000 * clock speed / 1024)
}  // end of setup

void loop() { }

I have no idea how this fits in with a 595 however.

This may help: