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
 
Tools
Old 29th October 2009, 12:06 PM   #16
Default

Quote:
Originally Posted by Mike, K8LH View Post
Your 16F873 and 16F874 will count to 50-MHz. Look at parameters 41 Tt0L and 42 Tt0P in TABLE 15-4: TIMER0 AND TIMER1 EXTERNAL CLOCK REQUIREMENTS. That same table indicates that Timer 1 in asychronous counter mode is only good up to about 16-MHz.

Your 16F873 and 16F874 can read the 1:256 prescaler by toggling the T0SE edge select bit as described in my previous post.
...
Ok, the light bulb finally went ON. I now see the trick of clocking the prescaler until it increments TMR0 to determine where it stopped after the TOCKI input was gated off. Presumably, this is also the method by which the prescaler starts the next count cycle from zero?
__________________
Mike ML.
MikeMl is offline  
Old 29th October 2009, 12:46 PM   #17
Default

Hi. The trick of extracting prescaler value by toggling T0SE bit til TMR0 increases seems very interesting, but it doesen't work for me. I'm testing it in Proteus VSM simulator wit a pic16f630. Do you know if it works on real-life pics. Thanks.
pierlu is offline  
Old 30th October 2009, 01:09 PM   #18
Default

Perhaps a Proteus VSM problem? It works in "real-life" PICs just fine. I've used it so far in frequency counters using the 12F683, 16F628A, and 16F88.

Have fun Gentlemen.

Regards, Mike

Last edited by Mike, K8LH; 30th October 2009 at 01:13 PM.
Mike, K8LH is offline  
Old 30th October 2009, 03:24 PM   #19
Default

It doesen't work neither with MPLAB SIM (I can only test on simulators at the moment), but it works perfectly toggling T0CS instead of T0SE. Thank you very much for the inspiration.

P.S.
I hope you can understand my english.

Bye

Pierluigi
pierlu is offline  
Old 30th October 2009, 03:27 PM   #20
Default

The problem with toggling the T0CS bit as that the prescaler may start clocking the system clock during the short time that the system clock is selected as the source. I wonder if you're missing something as simple as making sure the T0CKI pin is set as an output before you start toggling T0SE?

Last edited by Mike, K8LH; 30th October 2009 at 03:28 PM.
Mike, K8LH is offline  
Old 30th October 2009, 03:38 PM   #21
Default

I think the code is OK.

Code:
start
	bsf STATUS,RP0			; Set tmr0 as counter
	movlw b'11100111'		; on rising edge with 1:255 prescaler.
	movwf OPTION_REG		;
	bcf TRISA,2				; Set tmr0_pin as output.
	bcf STATUS,RP0			;

	clrf TMR0

	call toggletest

	goto start

toggletest
	movf TMR0,W
	movwf temp
	clrf count

toggle
	incf count,F
	bsf STATUS,RP0
	bsf OPTION_REG,T0SE
	bcf OPTION_REG,T0SE
	bcf STATUS,RP0

	movf TMR0,W
	subwf temp,W

	btfsc STATUS,Z
	goto toggle

	comf count,F
	incf count,F
	return
When I'll have a real pic I will try again. For now using T0CS instead is good for me.

Thank you.

Bye.
pierlu is offline  
Old 30th October 2009, 03:46 PM   #22
Default

You're setting the RA2 pin as an output. Is that the T0CKI pin for the PIC source code you're testing? T0CKI is on the RA4 pin on some PICs.

Mike

<added>

I see now that your 16F630 has T0CKI on RA2...

Last edited by Mike, K8LH; 30th October 2009 at 03:51 PM.
Mike, K8LH is offline  
Reply

Tags
100mhz, counter, frequency, frequency counter

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Frequency Counter Powzoom Electronic Projects Design/Ideas/Reviews 1 30th January 2009 11:21 PM
100mhz oscillator circuit gray5596 Electronic Projects Design/Ideas/Reviews 6 9th May 2008 02:59 PM
Frequency counter yasser11 Electronic Projects Design/Ideas/Reviews 2 5th April 2006 04:49 PM
Frequency Counter Gregory Electronic Projects Design/Ideas/Reviews 4 28th January 2006 03:16 PM
frequency counter samcheetah Electronic Projects Design/Ideas/Reviews 4 5th May 2004 11:42 PM



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


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker