Circuit Digital Clock Using PIC16f628a Microcontroller Schematics

Category : circuit » circuit Electronics » Electronic schematics » electronics » Electronics Board » MICROCONTROLLER » schematics This is a very basic digital clock that can be done using a microcontroller. I particularly used a PIC16f628a. You can also check my digital clock based on 74ls90 here –> http://www.circuitlab.org/2008/12/digital-clock-based-on-74ls90.html Read more: http://www.circuitlab.org/2008/04/circuit-digital-clock-using-pic16f628a.html#ixzz3Vw1q4xHz ….

You need to start up you’re clock at exactly 1200am/pm.
Circuit Digital Clock Using PIC16f628a Microcontroller Schematics——————————————-SOURCE CODE———————————————–

//Digital Clock using PIC16f628a microcontroller
//Design by: circuit_desolator
//Date: April 2011

#include<htc.h>

#define _XTAL_FREQ 4000000

__CONFIG(INTIO & WDTDIS & PWRTDIS & UNPROTECT & BORDIS & LVPDIS);

unsigned int hours = 0;
unsigned int mins = 59;

unsigned int timer = 0;
unsigned char mpx_cnt = 0;
static unsigned char mode = 0;

void interrupt ISR(void)
{

{
timer++;

if(timer > 19650)
{
mins++;
if(mins == 60)
{
mins = 0;
hours++;
if(hours == 13)
hours == 1;
}

timer = 0;
}
}

switch (mpx_cnt)
{
case 0:
PORTB = hours/10;
RA0 = 1;
mpx_cnt = 1;

case 1:
PORTB = hours%10;
RA1 = 1;
mpx_cnt = 2;

case 2:
PORTB = mins/10;
RA2 = 1;
mpx_cnt = 3;

case 3:
PORTB = mins%10;
RA3 = 1;
mpx_cnt = 0;
}

T0IF = 0;                //clear TMR0 interrupt flag
}
Circuit Digital Clock Using PIC16f628a Microcontroller Schematicsvoid init_Timers(void)
{
GIE = 0;

T0CS = 0;
PSA = 0;
PS2 = 0;
PS1 = 0;
PS0 = 0;

T0IF = 0;
T0IE = 1;
TMR0 = 6;

GIE = 1;
}

void main()
{
TRISA = 0x00;
TRISB &= ~0x0F;
TRISB |= 0xF0;

init_Timers();

while(1);
}

—————————————SOURCE CODE——————————————–

 

For more detail: Circuit Digital Clock Using PIC16f628a Microcontroller Schematics

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter