TMR0 counter problem

General discussion on mikroC.
Post Reply
Author
Message
scastagnoli
Posts: 16
Joined: 02 Dec 2006 13:37

TMR0 counter problem

#1 Post by scastagnoli » 23 Feb 2011 01:40

Hi everyone,
I'm using MikroC 6.2 on a EasyPic6.
I use the following code with default parameters for project.
The device is 16F877A.

void main() {
unsigned short stato = 0;
TRISA = 0xFF;
TRISB = 0;
PORTB = 0xFF;
OPTION_REG.F5 = 1;
OPTION_REG.F4 = 0;
OPTION_REG.F3 = 1;

TMR0 = 10;
Usart_Init (2400);
Usart_Write (TMR0);
while (1)
{
if (Button (&PORTA, 1, 1, 1))
stato = 1;
if (stato && Button (&PORTA, 1, 1, 0))
{
stato = 0;
Usart_Write (0xAA);
}
if (TMR0 == 15)
{
Usart_Write (0xFF);
TMR0 = 10;
}
}
}

I simply would use TMR0 as a counter but I cannot make it respond on RA4 pression.
Can someone help me please?

Best Regards

Mince-n-Tatties
Posts: 2780
Joined: 25 Dec 2008 15:22
Location: Scotland

Re: TMR0 counter problem

#2 Post by Mince-n-Tatties » 27 Feb 2011 14:31

scastagnoli wrote:Hi everyone,
I'm using MikroC 6.2 on a EasyPic6.
6.2 why? everyone should (unless forced to use older) move to the mikroC pro compilers
Best Regards

Mince

Post Reply

Return to “mikroC General”