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.

Solved PIC Frequency counter - Interesting quandary

Status
Not open for further replies.

augustinetez

Well-Known Member
Most Helpful Member
I have 2 16F628A based Frequency counters, both using exactly the same code except one is using an external OCXO as the frequency ref and the other is using a 10MHz xtal.

Feeding 10MHz in (from the OCXO) to the xtal based unit and it reads 20MHz, feeding the same signal to the OCXO based unit and it reads correctly at 10MHz.

The only difference between the two units are slight differences in component values of the input circuit as below. Input stage 1 is the 10MHz xtal version and Input stage 2 is the OCXO version (and yes, the input stage really needs updating to something better - on the 'todo' list).

Any one seeing something I'm not (apart from the 270Ω resistor in one of the units) ?

Input.jpg
 
Even the 16 and 24-bit (SMT) timers can have a prescaler assigned to them, and once you use that you limit the resolution if you don't account for the prescaler.

But, I agree... if you only want to mimic the old PIC16 circuits with an 8-bit TMR0 then you can just set the prescaler to 1:1 and use a 16-bit timer.
 
There are plenty of 16 bit (and even 24 bit) timers on modern PIC's, so no need for tricks to read the pre-scaler.
Some missing context, if I may? The 8-bit TMR0 with prescaler was often used because it could count signals up to 50 MHz while the other timer inputs topped out at much lower frequencies.
 
Last edited:
Some missing context, if I may? The 8-bit TMR0 with prescaler was often used because it could count signals up to 50 MHz while the other timers topped out at much lower frequencies.
As far as I'm aware the limitation was that TMR0 was the ONLY timer on the antique OTP devices that the app note used, and modern devices have many more (and better) timers - but have kept TMR0 for compatibility reasons.

Here's one (with quite an old PIC) using TMR1.

 
As far as I'm aware the limitation was that TMR0 was the ONLY timer on the antique OTP devices that the app note used, and modern devices have many more (and better) timers - but have kept TMR0 for compatibility reasons.
I'm sorry. I have absolutely no idea what app note you're referring to.
Here's one (with quite an old PIC) using TMR1.

Oh my! I stopped visiting that site long ago after catching errors in his projects. I tried to bring one to the attention of the administrator but didn't get a response.

The datasheet for the 16F877A used in that project might be useful. In counter mode, TMR0 should be able to handle input signals up to around 50 MHz while TMR1 should get up to around 16 MHz.

Cheerful regards, Mike

Freq Counter Timing.png
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top