Searching \ for 'PIC16F84 timer0 problems' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/time.htm?key=time
Search entire site for: 'PIC16F84 timer0 problems'.

Truncated match.
PICList Thread
'PIC16F84 timer0 problems'
1999\04\22@121557 by hno

flavicon
face
Hi piclisters

Sorry to bother you all again, but I am experiencing some trouble with
timer0. When I initialize the timer, and enable the interrupts, they start
to roll in, even though I have set the source of input to RA4.
I think my setup of the timer is pretty straight forward, and so is my
interrupt handling, but I can't figure out what this problem can be. When I
run the program, I first setup the timer, and after that I enable the
interrupts.
I have placed my timersetup below, and I really hope that some of you can
help me.
Once again, excuse me for taking up your time, but I am quite new in
picprogramming, and I am really stuck here.

Thanks for your help
Henrik Nowak
Electronics Engineer Student
spam_OUThnoTakeThisOuTspampost3.tele.dk

void SetupTimer0()
{
 TMR0        = 0x00;            // Clear Timer0 and prescaler.
 OPTION.PS0  = 0;            // Set prescaler value here.
 OPTION.PS1  = 0;
 OPTION.PS2  = 0;
 OPTION.PSA  = 0;           // Set prescaler to be used with timer.
 OPTION.T0CS = 1;           // Set to counter mode.
 OPTION.T0SE = 0;           // Increment on rising edge
}

1999\04\23@040028 by org Hager

flavicon
face
On Thu, Apr 22, 1999 at 06:14:19PM +0200, Henrik Nowak wrote:
>
> When I initialize the timer, and enable the interrupts, they start
> to roll in, even though I have set the source of input to RA4.

Hi!

Do you reset the T0IF bit in the INTCON register upon entry
into your interrupt routine? This bit has to be reset
by software, or you will get a new interrupt every time
the timer 0 int gets enabled again (e.g. by RETFIE).

Georg.

1999\04\23@041935 by hno

flavicon
face
Hi

Yes, when i'm done in my interrupt handler i reset the T0IF bit, but still
the timerinterrupts occurs. There is a little delay between them, as if the
pic is really counting some sort of signal. Basicly I use the same
handlersource for the timerinterrupt and the RB0 interrupt,  and the RB0
interrupt works just fine.

-----Oprindelig meddelelse-----
Fra:    Georg Hager [SMTP:.....ghagerKILLspamspam@spam@THEORIE3.PHYSIK.UNI-ERLANGEN.DE]
Sendt:  23. april 1999 10:00
Til:    PICLISTspamKILLspamMITVMA.MIT.EDU
Emne:   Re: PIC16F84 timer0 problems

On Thu, Apr 22, 1999 at 06:14:19PM +0200, Henrik Nowak wrote:
>
> When I initialize the timer, and enable the interrupts, they start
> to roll in, even though I have set the source of input to RA4.

Hi!

Do you reset the T0IF bit in the INTCON register upon entry
into your interrupt routine? This bit has to be reset
by software, or you will get a new interrupt every time
the timer 0 int gets enabled again (e.g. by RETFIE).

Georg.

1999\04\23@092147 by Mike Keitz

picon face
On Fri, 23 Apr 1999 09:59:30 +0200 Georg Hager
<.....ghagerKILLspamspam.....THEORIE3.PHYSIK.UNI-ERLANGEN.DE> writes:

>Do you reset the T0IF bit in the INTCON register upon entry
>into your interrupt routine? This bit has to be reset
>by software, or you will get a new interrupt every time
>the timer 0 int gets enabled again (e.g. by RETFIE).

Also, the T0IF bit is set whenever the timer overflows, whether
interrupts are enabled or not.  It is only set by hardware and must be
cleared by software.  It is possible that an overflow will occur before
your program gets around to initializing the timer.  So your software
should reset T0IF before enabling the interrupt or there could be an
unintended interrupt immediatly after the enable flag is set.  Of course
in some cases that won't matter, if you're just using the timer interrupt
as a time base for example.

If you combine this effect with not properly clearing the flag in the
ISR, a spurious first interrupt will start the PIC hanging up in constant
interrupts even without any clock input to the timer.


___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...