Timer 0 Querry

General discussion on mikroC.
Post Reply
Author
Message
Rob1234
Posts: 31
Joined: 11 Aug 2009 04:13

Timer 0 Querry

#1 Post by Rob1234 » 17 Oct 2010 04:16

Dear readers

I have a small doubt with timer..

The timer0 of a P16F877a is configured with internal clock source and a Prescaler 1:2 with a Fosc = 1 Mhz.

The datasheet specifies that the Timer0 register reads from 255 - 0 and then rolls over.

when a Value is being entered in the timer0 register.. for example 200 ..

A)does the timer read from 255 to 200 and then rolls over.? setting up the INT flag ..

B)When the timer0 Register is observed on a LCD .. the value goes even below 200 ? How ?

Ur gudiance will be most welcome.

-Rob

KaranSoin
Posts: 130
Joined: 07 May 2010 22:27
Location: Melbourne, Australia

Re: Timer 0 Querry

#2 Post by KaranSoin » 17 Oct 2010 06:42

The Timer0 Counts up and rolls over (0...254-255-0,1). When it goes from 255 to 0, it generates an interrupt. When you set the tmr0 to 200, it counts up from 200 going to 255 and then rolling over to 0.

Regards

Rob1234
Posts: 31
Joined: 11 Aug 2009 04:13

Re: Timer 0 Querry

#3 Post by Rob1234 » 18 Oct 2010 05:02

Yup karan. Thank u but When observing the TMR0 Register of Timer 0 with a config Internal Oscillator..the value on the LCD..goes even below than the one entered in the TMR0 register.. Mayb i gotta to check ma compiler.hmmm


will do that and post a reply ..
thank u karan..

KaranSoin
Posts: 130
Joined: 07 May 2010 22:27
Location: Melbourne, Australia

Re: Timer 0 Querry

#4 Post by KaranSoin » 18 Oct 2010 09:06

another suggestion, check how you are displaying the TMR0 on the LCD, if ur LCD routine treats the TMR0 as a signed value, then any value above 127 will interpreted as a -ve number.


cheers

Rob1234
Posts: 31
Joined: 11 Aug 2009 04:13

Re: Timer 0 Querry

#5 Post by Rob1234 » 19 Oct 2010 06:11

Hmm i use Unsigned int & long as my declarations and checked them with both..
I'll post my code ASAP

Post Reply

Return to “mikroC General”