Programmable Clock Source

Thread Starter


Joined Dec 23, 2010
Hi everybody,

I have to control a series of 8 cascade shift registers with one PIC, and I thought about manage the CLK input of all the shift registers in the firmware. The circuit is a LED cube and the firmware will be developed in C.

As I want to obtain multiple different stages with different speed, I had this idea..
The simple instruction I will use in many loops including properly timing delays, will be just this one:
Rich (BB code):
CLK = CLK ^ 1;
If I would like to source the clock of the shift registers at the greatest frequency obtainable, I just will need to leave the instruction executing at the execution time imposed by the working frequency of the microcontroller.
Differently, if I would like to obtain a slower frequency for the registers, I just will use properly delays. It seems a good approach to me. In this way I can also handle exactly on which clock transition (could be positive or negative) input the serial data input at an exact moment.
For example if the shift register accepts the serial-in data on a PGT (positive going transition), in a loop, depending on the value of the counter I can know if CLK is 0 or 1 and manage the data depending on it.
Also, knowing that the instruction cycle time of a PIC is about 4 clock transitions, and if I have to know how many clock cycles I need to handle the outputs, I am quite convinced in using this technique.

I would like to know what you think about it, could be very useful and maybe another or better ideas can be proposed. :)

I have a last question. Could I change the internal oscillator frequency by changing the OSSCON register during firmware execution? I have never do it...

Thank you.
Best regards,
Last edited:
Well i don't fully understand all of this post... but if you do this, your processor will spend all its time just generating the clock. You won't be able to do anything else. It's probably better to use a much faster master clock for your micro and use timers and interrupts to generate your shift register's clock.