code for tmr0 in mikroc pro

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
nsreen
Posts: 5
Joined: 01 Dec 2011 07:49

code for tmr0 in mikroc pro

#1 Post by nsreen » 01 Dec 2011 08:10

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

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: code for tmr0 in mikroc pro

#2 Post by janko.kaljevic » 01 Dec 2011 10:39

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.

nsreen
Posts: 5
Joined: 01 Dec 2011 07:49

Re: code for tmr0 in mikroc pro

#3 Post by nsreen » 01 Dec 2011 13:50

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 :)

nsreen
Posts: 5
Joined: 01 Dec 2011 07:49

Re: code for tmr0 in mikroc pro

#4 Post by nsreen » 01 Dec 2011 13:52

thnx it is work nw :)

Post Reply

Return to “mikroC PRO for PIC General”