Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 16th November 2007, 03:04 AM   (permalink)
Question How to Reset TMR2?

Hi I have setup TMR2 in the beginning of the program.Now I need to reset TMR2 in the middle of the program by pressing a button.

what i want to know is do I need to write all this lines including PR2 register,pre scaler etc.. or only bsf INTCON,PEIE is enough for reset the TMR2?

Code:
	movlw	.249
	movwf	PR2
	bsf	INTCON,PEIE
	bsf	INTCON,GIE
Suraj143 is offline  
Old 16th November 2007, 03:39 AM   (permalink)
Default

Just turn it off with bcf T2CON,TMR2ON.

Mike.
Pommie is online now  
Old 16th November 2007, 04:17 AM   (permalink)
Default

Oh I see its very simple.Ok I'll turn that TMR2ON bit OFF & ON to make it reset.

Thanks mike.
Suraj143 is offline  
Old 16th November 2007, 08:51 AM   (permalink)
Default

Quote:
Oh I see its very simple.Ok I'll turn that TMR2ON bit OFF & ON to make it reset.
Turning the timer off and on won't reset it, it will just stop it with what ever value is in it.

Since it's an 8 bit timer you can just use CLRF TMR2 without stopping it which will clear both the pre and post scalers at the same time.
__________________
Pete
picprojects.org.uk
geko is offline  
Old 16th November 2007, 09:00 AM   (permalink)
Default

Quote:
Originally Posted by geko
Since it's an 8 bit timer you can just use CLRF TMR2 without stopping it which will clear both the pre and post scalers at the same time.
OMG then I have to setup all PR2 & prescaler lines as well after clearing TMR2.
Suraj143 is offline  
Old 16th November 2007, 10:10 AM   (permalink)
Default

No, it's not that bad.

The pre and postscaler ratios aren't changed neither is the value you've already loaded into PR2.

The pre and post scalers are counters themselves. Writing to TMR2 (any value) sets these back to zero automatically.

It's all in the datasheet by the way.
__________________
Pete
picprojects.org.uk
geko is offline  
Old 16th November 2007, 10:18 AM   (permalink)
Default

Quote:
Originally Posted by geko
The pre and postscaler ratios aren't changed neither is the value you've already loaded into PR2.
I haven't heard this before.

Quote:
The pre and post scalers are counters themselves. Writing to TMR2 (any value) sets these back to zero automatically.
OK I'll add clrf TMR2 after pressing the button in the coding.
Suraj143 is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Brown-out reset on LF PIC bananasiong Micro Controllers 10 17th May 2007 01:33 AM
single-sided pcb layout challenge Mike, K8LH Micro Controllers 25 5th May 2007 10:32 PM
74LS90 power-on auto reset Torben Electronic Projects Design/Ideas/Reviews 17 20th December 2006 05:18 AM
vx-5r reset problem tom muleady General Electronics Chat 2 5th July 2006 07:01 PM
uC 'network' reset circuitry rockin_rick Electronic Projects Design/Ideas/Reviews 8 30th May 2006 02:03 AM



All times are GMT. The time now is 02:04 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker