how to calculate CPU usage of a 87c51 microcontroller

Discussion in 'Embedded Systems and Microcontrollers' started by phaneesh.siva, Sep 2, 2010.

  1. phaneesh.siva

    Thread Starter New Member

    Sep 2, 2010
    3
    0
    hi all,
    iam using Intel 87c51fb microcontroller in one of my projects. i would like to know the usage of CPU(% of cpu usage), please help me how to calculate the cpu usage of this microcontroller.
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    The CPU usage will be 100% always. What is more important is timing. Like say if you use timer to generate timed intervals with an interrupt service routine. Then it is very important that the MCU is able to finish all work in the service routine and return from it (preferably with a good margin) before a new interrupt occurs. Most development enviroment will be able to help you in doing this kind of calculation
     
  3. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    You need to be more specific about the conditions. If the algorithm running on the 87C51 puts the processor to SLEEP then the utilization is no longer 100%. Keeping track of real time while the processor is asleep can be either precise or can be an educated guess. How important is the actual number?
     
  4. DonQ

    Active Member

    May 6, 2009
    320
    11
    With what I do, it's more important to determine how much time is spent in interrupt routines. I just set a bit on entry, and clear it on exit. Then it is a simple matter to see this on a scope. Even an averaging voltmeter can give you a good estimate of percent time spent in the routine.

    Specific routines can be done the same way.

    Or if you are running some sort of time-share system, and have a lowest priority "idle" process, just toggle the bit quickly there, when it is not toggling, you know you are somewhere else, doing real work.

    If you are worried about the overhead of the time spend toggling the bit, or being off by a half-cycle using the "idle" toggle, or not counting the interrupt latency, then you don't need to know anything else. If you're worried about timing at this level, you are certainly desperately underpowered.
     
  5. phaneesh.siva

    Thread Starter New Member

    Sep 2, 2010
    3
    0

    in my application i am using three interrupts, highest priority is given to serial interrupt. timer0 and int0 are of equal priority. int0 interrupt will be coming for every 20 msec and sytem is required to respond to the interrupt within 3 msc, this is the only task which is taking about timing and all other things are not time critical. timer0 is used to send some data to external device through serial port.
     
Loading...