Page 1 of 1

code for tmr0 in mikroc pro

Posted: 01 Dec 2011 08:10
by nsreen
using tmr0 at pic 16f877a to make 10 min delay or what ever the delay using 4 MHz oscillatory i tried to write the code but there is error and this is the code
unsigned i;
void interrupt(){
intcon = 0b00100000;
i++;
if (i==305)
portd=1;
tmr0if_bit=0;
tmr0=0;

}
void main() {
intcon = 0b10100000;
option_reg = 0b00000111;
trisd=0;
trisb=0;
PORTB=0;
portd=0;
tmr0=0;
i = 0;
while(1)
{
if(tmr0if_bit=1){
interrubt;
}
}
}

and thanks in advance

Re: code for tmr0 in mikroc pro

Posted: 01 Dec 2011 10:39
by janko.kaljevic
Hello,

I do not know whether there are typing mistake or not, but you can not call interrupt function from your code.
And if you are doing polling you do not need interrupt function.

You can check timer interrupts examples in examples folder in compiler.

Best regards.

Re: code for tmr0 in mikroc pro

Posted: 01 Dec 2011 13:50
by nsreen
janko.kaljevic wrote:Hello,

I do not know whether there are typing mistake or not, but you can not call interrupt function from your code.
And if you are doing polling you do not need interrupt function.

You can check timer interrupts examples in examples folder in compiler.

Best regards.
thnx it is work :)

Re: code for tmr0 in mikroc pro

Posted: 01 Dec 2011 13:52
by nsreen
thnx it is work nw :)