CAN I read 100Khz frequency using MC9S12XHZ512

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAN I read 100Khz frequency using MC9S12XHZ512

462 Views
kdn
Contributor III

CAN I read 100Khz frequency using MC9S12XHZ512 Micro-controller ?

Labels (1)
Tags (1)
0 Kudos
2 Replies

264 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

I would like to add. There are two methods of frequency measurement.

1) Counting of BUSCLK/PRESCALER periods of internal timer between two incoming external pulses. This is suitable for lower frequencies. For higher frequencies it is not suitable because there is to high difference between two measurable frequencies.

The measurement precision is df which can be expressed as: df = BUSCLK / ((n^2 + n) * PRESCALER); n = measured number of TCNT periods

For example: BUSCLK = 16MHz, PRESCALER = 1

nfdfnfdfnfdfnfdfnfdf
1800000053333332622792,021628,002516033,183227,6673762734,10870,105331011553,09630,15721
2266666713333332721164,021459,588525805,515215,0191772664,00367,443111021522,93929,28729
31333333533333,32819704,431313,629535590,496203,2908782596,5664,913991031493,65228,45051
4800000266666,72918390,81186,504545387,205192,4002792531,64662,509771041465,20127,64531
5533333,31523813017204,31075,269555194,805182,2739802469,13660,222821051437,55626,87021
6380952,495238,13116129,03977,5171565012,531172,8459812408,91358,04611061410,68626,12381
7285714,363492,063215151,52891,2656574839,685164,0571822350,86755,973021071384,56225,40481
8222222,244444,443314260,25814,8714584675,628155,8543832294,89453,99751081359,15724,71195
9177777,832323,233413445,38746,9655594519,774148,1893842240,89652,113871091334,44524,04406
10145454,524242,423512698,41686,4007604371,585141,0189852188,78250,316841101310,40123,40002
11121212,118648,023612012,01632,2112614230,566134,3037862138,46648,601491111287,00122,77878
12102564,114652,013711379,8583,5795624096,262128,0082872089,86446,963241121264,22322,17934
1387912,0911721,613810796,22539,8111633968,254122,1001882042,90145,39781131242,04321,60075
1476190,489523,813910256,41500,3127643846,154116,5501891997,50343,901171141220,44221,04211
1566666,677843,137409756,098464,5761653729,604111,3315901953,60242,469611151199,420,50257
1658823,536535,948419291,521432,1638663618,272106,4198911911,13241,099621161178,89819,98132
1752287,585503,956428859,358402,6981673511,853101,7928921870,03339,787931171158,91619,47759
1846783,634678,363438456,66375,8515683410,0697,43028931830,24538,531471181139,43918,99065
1942105,264010,025448080,808351,3395693312,62993,3135941791,71337,327361191120,44818,5198
2038095,243463,203457729,469328,9136703219,31689,42544951754,38636,172911201101,92818,0644
2134632,033011,481467400,555308,3565713129,8985,75042961718,21335,065571211083,86417,6238
2231620,552635,046477092,199289,4775723044,1482,27405971683,14734,002981221066,2417,19742
2328985,512318,841486802,721272,1088732961,86678,98309981649,14532,982891231049,04316,78468
2426666,672051,282496530,612256,1024742882,88375,86534991616,16232,00321241032,25816,38505
2524615,381823,362506274,51241,3273752807,01872,909551001584,15831,061931251015,87315,998

2) counting incoming external pulses during defined period. It is clear that this measurement is not suitable for low frequencies which require long test period.

So you have to do some compromise if you want to measure wide frequency range or create more complex solution.

0 Kudos

264 Views
lama
NXP TechSupport
NXP TechSupport

The MCU busclock can work up to 40MHz. You need minimally 2busclocks to recognize edge. So, if I think about 2 clocks for rising edge and 2 clocks for falling edge then maximum frequency you can measure is 40MHz/4 = 10MHz. The issue is how you want to calculate it. Let's consider 100.000kHz frequency of rising edges. In this case you have 10us to process the value which means 400buscycles @ 40MHz busclk.

In dependence on processing time you can:

  • Perform measurement for each period of input signals when the processing time is shorter then measured period.
  • Perform measurement in acceptable sensing periods when the frequency is high and processing time is long. Captured new and old values are read in the loop and used only when necessary
  • If the frequency is stable you can perform measurement by counting pulses within known interval and then calculate mean frequency within period.

As an example I have attached two example project for another MCU but the same approach.

BTW; please do not ask me how to do it in Processor Expert. I do not use it.

If you see this answer as correct answer please mark it as correct and helpful to help others to find good answers faster. Thank you in advance.

Best Regards, Ladislav

0 Kudos