The schematic of the 10-Second counter
Project setting of MikroC for using internal oscillator of the PIC16f627a.
The firmware is written in MikroC and you can find it below.
//PIC16F627A
//4MHz Internal OSC
// One Digit Counter
// 06/11/2008
//Punkky
unsigned short counter;
unsigned short tick;
void interrupt ()
{
PIR1.TMR1IF = 0; // clears TMR1IF
TMR1H = 0x80;
tick = 1;
}
void main(){
CMCON = 0x07; //Digital I/O for PORTA
TRISA = 0x00;
PORTA = 0x00;
TRISB = 0x00;
PORTB = 0x00;
T1CON = 0x0F;
// Prescaler 1:1 external clock
PIE1.TMR1IE = 1; // enable interupt to start the clock
INTCON = 0xC0; // Set GIE, PEIE
TMR1L = 0x00;
TMR1H = 0x80;
PCON.OSCF = 1; //Internal Clock 4MHz
//PCON.OSCF = 0; //Internal Clock 48KHz doesn't work well
counter = 0;
tick = 0;
PORTA.F0 = 1; // Enable 4345 BCD to 7-Segment
while(1){
if(tick){
tick = 0;
counter++;
PORTB = counter;
if(counter>9){
counter = 0;
}
}
}
}
1 comment:
Hi would this project be compatible with PIC16f877a?
Post a Comment