[En-Nut-Discussion] Measuring idle time

Nathan Moore nategoose at gmail.com
Mon Oct 26 16:22:36 CET 2009


Hello all.
>
> We are debugging one application in Ethernut3, and we want to measure
> the time that the micro spends doing some tasks. For that we are setting
> different pins up and down and measuring times with the oscilloscope.
>
> To measure the idle time we are setting up one of the pins during the
> execution of the idle thread. I am sure that many people have been
> thinking about/doing this, so I wonder if NutOS provides some kind of
> debug option or mechanism to do this already.
>

I did this once but there was no support in Nut for it.
I only had 3 gpio (LEDs in this case) available, but had less than 9 threads
including the idle
thread, so I added a uint8_t to the thread control block to represent the
LED pattern.
I also added code in NutThreadCreate to count how many times it had been
called and store that
in each thread block.
Then I added code in task switching to set all of my gpio to 0 while doing
thread switching and
set them to the pattern of the runningThread when a new thread had been
scheduled based on
the variable I had added to the thread control block.
I then added code in my main thread to print out the thread names and their
LED pattern after all
my threads were created but before the main thread entered it's normal
running state (loop).
   idle      = 001
   main    = 010
   TcpSm = 011
   A         = 100
   B         = 101
   C         = 110

Task switching would be 000
If you have enough gpio available I would suggest strongly using only a
single bit per thread rather
than a bit pattern since it's easier to scope and measure.


Nathan



More information about the En-Nut-Discussion mailing list