Sorted it now. It was the bloody function generator! Why oh why did i suspect my code? Thanks anyway, Graham Michael Rigby-Jones wrote: > -----Original Message----- > From: Graham North [SMTP:graham_from_malton@YAHOO.CO.UK] > Sent: Thursday, July 03, 2003 9:38 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]: 18FXX20 Timer 3 as external counter? > > Ops, forgot the tag last time. > > Hi everyone, > > I'm trying to use Timer 3 on the 18F8720 to count the number of pulses. I > have a function generator connected to RC0 outputing a square wave, but am > getting nothing. > > Timer 3 is set up as below: > > ;*********************************************************************** > ; Timer 3 -- Used to count the count. > ;*********************************************************************** > movlw B'00000110' ; Timer 3 Off, No Prescale, Not Sychronised > movwf T3CON ; Ext input > bcf IPR2,TMR3IP ; Timer 3 low priority interrupt > bsf PIE2,TMR3IE ; Timer 3 Interrupt enable > clrf TMR3H > clrf TMR3L > bsf T3CON,TMR3ON ; Start Timer 3 (Count) > > > I'll try and describe what I'm trying to do here. I have a circuit > outputting pulses, I want to count how many I get in 25ms. The max freq > the pulses will be is 100kHz, so the 16 bit counter should never overflow. > The interupt is there just incase something screwy happens and it does > overflow. > > So every 25ms I read TMR3L and TMR3H, then clear them, wait 25ms and read > them again, forever! I currently have a function generator attached to RC0 > putting in a square wave to simulate the circuitry. Every time I read > TMR3L and TMR3H they are zero. > > Have I done something stupid? Or missed something obvious? I've been > trying to debug this all afternoon with no luck. > > The first thing that springs to mind is that you have cleared bit 0 of T3CON which means that timer 3 is stopped: movlw B'00000110' ; Timer 3 Off, No Prescale, Not Sychronised Should be movlw B'00000111' Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= Any questions about Bookham's E-Mail service should be directed to postmaster@bookham.com. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. --------------------------------- Want to chat instantly with your online friends? Get the FREE Yahoo!Messenger -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.