The schematic of the 10-Second counter
![Schematic of 10-Second counter](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYkY8ncIYkSsGPoS4YShInFZJSh_qb-0tFhgChTZfeJLCRE6eVTwrH_0_u61hjLyA7k9gR1LuI9J1UIy3_Prfz3Bx1_3pNZgbKA5Z-RT6jDA7vBEmFbUUeL0VHhAYm4ofGLcCN-chCVLy5/s280/7-segment-mcu.png)
Project setting of MikroC for using internal oscillator of the PIC16f627a.
![Setting MikroC for Internal Oscillator](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqHCb9fGrGNzefyj41hmrwzJ6E0rlzv3zehA3Y_DRNu1dJ5b8elW2uzkoFmIcOgDhKGmb4C7Cz3TwyuMhqa85qocBcI-Y597rTe5fNTmpxtfNzrb65E7uvagTc1_GOreNH58VDA3s63xiZ/s280/10sec-counter.png)
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;
}
}
}
}
Hi would this project be compatible with PIC16f877a?
ReplyDelete