Author Topic: PIC - timer0 up to 100MHz  (Read 2381 times)

0 Members and 1 Guest are viewing this topic.

Offline 0xFFF0Topic starter

  • Regular Contributor
  • *
  • Posts: 105
  • Country: de
PIC - timer0 up to 100MHz
« on: September 28, 2021, 09:28:33 am »
Are there modern PICs whose timer0/1/etc. can count up to the range of 100MHz or is this a MCU domain only?
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 5137
  • Country: bt
Re: PIC - timer0 up to 100MHz
« Reply #1 on: September 28, 2021, 09:58:11 am »
The vintage 16F84A/628 did 50MHz easily (timer0), so chances are the modern one PICs will do the double..
Readers discretion is advised..
 

Offline Tagli

  • Contributor
  • Posts: 31
  • Country: tr
Re: PIC - timer0 up to 100MHz
« Reply #2 on: September 28, 2021, 01:43:43 pm »
I doubt you can count 50 MHz signals with PIC16F628A which runs at 20 MHz max.

Synchronous counters can't count faster than MCU frequency. Timer0 falls into this category.
Asynchronous counters can be faster.

The values are available on datasheets. This is from PIC16F628A datasheet, where you can see that min period for async input for Timer1 needs to be 60 ns, so it's ~16.66 MHz signal.


PIC16F18444, which is suggested by Microchip to replace PIC16F628A, runs at 32 MHz but has similar values.

For comparison, a STM32F407 running at 168 MHz can count up to 84 MHz signals, which seems to be fTIMxCLK / 2.

So, finding a MCU that can count signals faster than 100 MHz is probably hard if not impossible.
Gokce Taglioglu
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13971
  • Country: gb
    • Mike's Electric Stuff
Re: PIC - timer0 up to 100MHz
« Reply #3 on: September 28, 2021, 02:06:16 pm »
Even the PIC32MZ, which has 200MHz CPU clock, shows a 50Mhz limit for async external clock.
If you really neeed that speed, an external CPLD is probably the simplest solution
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3249
  • Country: us
Re: PIC - timer0 up to 100MHz
« Reply #4 on: September 28, 2021, 02:33:28 pm »
The "50 MHz PIC Frequency Counter" originally created by Wolfgang "Wolf" Büscher, DL4YHF:

https://www.qsl.net/dl4yhf/freq_counter/freq_counter.html

and available on alix/ebay/bg/etc. uses the 16F628 prescaler which is an asynchronous series of JK flip-flops.

In practice it seems you can measure greater than 50 MHz.

This video has a good explanation of the prescaler in the 16F628 and its use in the "50 MHz Frequency Counter" design:

- PIC Frequency Counter: Fixing the pulse-width problem (and getting beyond 100 MHz) - TheHWCave
https://youtu.be/HVVcTv75RFs

If you just want to see how greater than 100 Mhz is achieved, skip to timestamp 12:53.

Btw - that youtube channel has other nice videos on modifying the frequency counter.


« Last Edit: September 28, 2021, 02:38:12 pm by ledtester »
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 5137
  • Country: bt
Re: PIC - timer0 up to 100MHz
« Reply #5 on: September 28, 2021, 02:58:24 pm »
Yep, I built aprx 5 counters with 16F84A and 628.
Timer0 does 50MHz easily. It has got an async prescaler - and you _can_ read out its content as well - that is the trick.. So something like 51.234567MHz on the display with 1 sec gate time (gating in a sw loop)..
« Last Edit: September 28, 2021, 03:08:50 pm by imo »
Readers discretion is advised..
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3249
  • Country: us
Re: PIC - timer0 up to 100MHz
« Reply #6 on: September 28, 2021, 03:05:53 pm »
...
It has got an async prescaler - and you can read out its content as well - that is the trick..
...

How do you do that? Inquiring minds want to know!

(ok - I think I just figured it out, but I'm interested in your answer.)
« Last Edit: September 28, 2021, 03:07:51 pm by ledtester »
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 5137
  • Country: bt
Re: PIC - timer0 up to 100MHz
« Reply #7 on: September 28, 2021, 03:11:01 pm »
That is an old trick since ever (around 2000)..  8)
470ohm resistor into the Timer0 (into the 78bits 50+ MHz prescaler). The frequency is fed in via that 470ohm (the resistor works as a "tristate buffer").
Also an additional pin wired to the Timer0 input (normally input).
After the 1sec gate measurement is done you set the pin to output and you clock-in pulses until the prescaler overruns.
Now you know the content of the prescaler..

Thus counting the instructions in a loop such you get 1sec (or other) gate time, then you read out 78 bits off the prescaler (high byte) then Timer0 (mid byte) and afaik you can increment Timer1 when Timer0 overflows (lowest byte)..
« Last Edit: September 28, 2021, 03:48:22 pm by imo »
Readers discretion is advised..
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19930
  • Country: gb
  • 0999
Re: PIC - timer0 up to 100MHz
« Reply #8 on: September 28, 2021, 03:33:04 pm »
Is there no room for the 74LVC1G74, which can be configured as a divide by two counter to generate 50MHz, from your 100MHz signal?
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 5137
  • Country: bt
Re: PIC - timer0 up to 100MHz
« Reply #9 on: September 28, 2021, 03:43:40 pm »
..
Thus counting the instructions in a loop such you get 1sec (or other) gate time, then you read out 78 bits off the prescaler (high byte) then Timer0 (mid byte) and afaik you can increment Timer1 when Timer0 overflows (lowest byte)..

Actually the prescaler is (8bits) the lowest byte, timer0 the mid byte, and timer1 the highest byte.
The prescaler counts till 256, you clocked-in say 68 pulses till the prescaler overan (->timer0 increments by 1), therefore the lowest byte is 256-68 (plus minus 1, as usual ;) ).

Edited the prescaler number of bits.. It is long time ago I messed with it. There is asm for that counter available, google for it..
« Last Edit: September 28, 2021, 03:50:39 pm by imo »
Readers discretion is advised..
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1859
  • Country: au
Re: PIC - timer0 up to 100MHz
« Reply #10 on: September 28, 2021, 09:22:42 pm »
Are there modern PICs whose timer0/1/etc. can count up to the range of 100MHz or is this a MCU domain only?

It's not a PIC but it is a small flash MCU - I connected a EFM8BB1 to a Si5351A clock generator,  and that bench tested fine to the 200Mhz limit on the Si5351A, with a suitable SysCLK prescaler value.
Flash limit is 25MHz or 50MHz on SiLabs MCUs so a /8 or more is needed to get to 200MHz.
ie the pin and the Logic divider tested ok to 200MHz, which is an indication of the typical 'newish' 8b MCU process.

The Config Logic inside many new MCUs can also divider faster than sysclk, I also tested this
EFM8LB1 using Async CLU/16 can Clock right up to 200MHz test limit

You could use any small MCU as a pin-selectable prescaler, with a few lines of code.

Other LOGIC family divider choices are parts like  74AHC1G4208 series - specs  > 125MHz at 3v3 and > 165MHz at 5v
These are like tiny-package 4060 parts, and include the Unbuffered inverter preamp.

Addit: Another 'process indicator' for low cost 8 bit MCUs can be found in the MG82F6D17
That specs 144MHz clock ability on the PCA counter, usually generated from a PLL, but the data does not clearly state if the external pin ECI choice, is SysClk sampled, or not.
 

Addit2: This is the 200MHz i2c clock generator used to test the examples above.  https://www.adafruit.com/product/2045
Web code can run this : Operation range from 10kHz to 225MHz
« Last Edit: September 28, 2021, 11:29:17 pm by PCB.Wiz »
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3249
  • Country: us
Re: PIC - timer0 up to 100MHz
« Reply #11 on: September 28, 2021, 11:40:58 pm »
...
This video has a good explanation of the prescaler in the 16F628 and its use in the "50 MHz Frequency Counter" design:

- PIC Frequency Counter: Fixing the pulse-width problem (and getting beyond 100 MHz) - TheHWCave
https://youtu.be/HVVcTv75RFs
...

Spotted this in the comments of that video about determining the value of the prescaler counter:

Quote
M K - 6 months ago
 @TheHWcave  Well, you don't have to use another pin.  You can simply toggle the Edge Select bit (T0SE) to do the clocking of the prescaler.  I've done it on a 16F1825 (currently on my breadboard), which has that same functionality as the 16F628.  And you would do that toggling after setting the input pin to "output" to "stop" the incoming signal while the toggling and calculation is done.
 
The following users thanked this post: PCB.Wiz

Online iMo

  • Super Contributor
  • ***
  • Posts: 5137
  • Country: bt
Re: PIC - timer0 up to 100MHz
« Reply #12 on: September 28, 2021, 11:58:43 pm »
Setting the timer0 input pin to output and toggling the T0SE may work as the fixed level (set to 0 or 1 before you set the timer0 pin to output) is then xored with T0SE. Nice..
PS: I saw in past they toggled it with the internal pullup too..
« Last Edit: September 29, 2021, 12:01:25 am by imo »
Readers discretion is advised..
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf