Sirs, Madams, I have found a progarm for 1hz clock generator and I want to test it. But it's using mikro C codes and I'm only familiar with mplab codes and I don't know how to convert this codes. Here they are:
// PIC12F675
// 1Hz Time Base Osc.
// Timer1 Module
// 32.768 KHz
unsigned short tick;
void Init ();
void interrupt ()
{
if (PIR1.TMR1IF)
{
TMR1H = 0xE0;
PIR1.TMR1IF = 0;
tick = 1;
}
}
void main ()
{
tick = 0;
//Initialize Ports and Timer1 Module
Init ();
while (1)
{
if (tick)
{
tick = 0;
GPIO = (1 << 2);
}
if (TMR1H > 0xF0)
{
GPIO = 0;
}
}
}
void Init ()
{
TRISIO = 0;
//Make all pins as output ports
GPIO = 0;
//Use Timer1 module
INTCON.GIE = 1;
INTCON.PEIE = 1;
T1CON = 0x01;
//Overflow every 8192
TMR1H = 0xE0;
TMR1L = 0x00;
// Enable TMR1 interrupt
PIE1.TMR1IE = 1;
}
I hope somebody can help me with this. Thanks in advance. I'm still a beginner with programming.
- - - Updated - - -
I hope someone can help me solve this problem. Please, just even help me with translating this codes, so that I can practice in doing it in MPLAB.