Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

100MHz frequency counter

Status
Not open for further replies.
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.
 
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:
Did toggling the T0SE from firmware increment the prescaler?

If so - this means we would need to have only the TMR0 pin connected to sample the signal leaving all other pins free!
 
Did toggling the T0SE from firmware increment the prescaler?

If so - this means we would need to have only the TMR0 pin connected to sample the signal leaving all other pins free!
It does increment the prescaler but I doubt if that "feature" was ever intended and so it doesn't surprise me that the Simulator doesn't know about it (LOL)...
 
Makes sense :)

Di you try this out in a simulator?

I am thinking of using TIMER1 in asynch mode - any working samples in C to read/start from?
 
Status
Not open for further replies.

Latest threads

Back
Top