1Hz Clock Generator using PIC12F675
Based on the idea from http://www.josepino.com/pic_projects/?timebaseI have created a 1Hz Clock Generator. I use PIC12F675 as it’s available locally. Its price is just about US$1.
The concept is using 32.768kHz crystal as a clock for the PIC. Therefor, the internal instruction clock is 32768/4 = 8192 Hz. By using the 16 bit Timer1 to count the instruction clock cycles, the interrupt will occur every 8 second. This period can be reduced by setting initial value of the Timer1 (TMR1H:TMR1L). I have to make Timer1 to count up to 8192 for generating overflow interrupt every 1 second. To make Timer1 count up to 8192, the initial value of TMR1 must be 65536-8192 = 57344 or 0xE000. This means TMR1H = 0xE0 and TMR1L = 0x00. In this case, I need to set only the TMR1H=0xE0 and let TMR1L runs continuously. By changing the initial value of Timer1, I can generate almost any frequencies.
An application for this project is a precise 1Hz blinking LED signal 🙂 ha ha. I know that it’s not useful but I think it’s fun to look at (am I crazy?). Another application is a precise 1Hz time base for a clock.
The source code is written in MikroC.
// 1Hz Time Base Osc.
// Timer1 Module
// 32.768 KHz
unsigned short tick;
void Init ();
void interrupt ()
TMR1H = 0xE0;
PIR1.TMR1IF = 0;
tick = 1;
void main ()
tick = 0;
//Initialize Ports and Timer1 Module
tick = 0;
GPIO = (1 << 2);
if (TMR1H > 0xF0)
GPIO = 0;
void Init ()
For more detail: 1Hz Clock Generator using PIC12F675
For All Your PCB Need, One-stop PCB Solution Services Appear:
EasyEDA: free PCB design tool, 200,000+ engineers are using
PCBs: 10pcs 2-layer 10x10cm only $8.21, on-time global shipping
Components: save 50% on cost, save on freight if shipped with ordered PCBs
Current Project / Post can also be found using:
- 1 Hz time base for microcontroller design
- 1 hz clock generator circuit
- PIC 1hz
- генератор на pic12f675