Get MCU running frequency in a variable ( realtime)
Posted: Sun Feb 05, 2012 8:36 pm
ok , so i wanted to ask this in my previous thread about this but from some strange reason i am returned to index when i press "post reply" button..(yes..i am logged in)..anyway..
I want to run my 16f88 with a external clock source that is variable..so i will have a variable MCU speed..question is how can i get the current speed that the MCU is running in a variable? the speed update must happen fast..i need this for calculating a formula that is based on the MCU system clock. Thank you forum
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
Posted: Mon Feb 06, 2012 2:43 am
You can't, unless you have some other clock that is constant available.
It is trivial to do if (for instance) you have timer1 running off an external 32KHz crystal, where you can just take a measured interval using this, and count how many processor clock cycles this involves, but without another reference you are basically stuck.
You could get a 'rough' estimate based upon doing something like charging a capacitor from a pin and timing how long this takes to discharge through a fixed resistor, again counting processor cycles.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum