You need to start up you’re clock at exactly 1200am/pm.
——————————————-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
}
void 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
The post Circuit Digital Clock Using PIC16f628a Microcontroller Schematics appeared first on PIC Microcontroller.