36
July 2014 The Quest For Power How Microchip’s MPLAB ® REAL ICE™ Power Monitor can help reduce the energy consumption of your product's hardware The ancient Greek philosopher Plato once said: The measure of a man is what he does with power. For modern, portable, embedded systems one could paraphrase: The measure of a product is how little power it uses, and in this webinar we will look at how a measure of this important hardware attribute can be obtained using the MPLAB REAL ICE and Power Monitor plug-in board.

The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

July 2014

The Quest For Power

How Microchip’s MPLAB® REAL ICE™ Power Monitor can help reduce the energy

consumption of your product's hardware

The ancient Greek philosopher Plato once said: The measure of a man is what he does with power. For modern, portable, embedded systems one could paraphrase: The measure of a product is how little power it uses, and in this webinar we will look at how a measure of this important hardware attribute can be obtained using the MPLAB REAL ICE and Power Monitor plug-in board.

Page 2: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Why Measure Power?

2

It is actually energy consumption that is critical for embedded projects that require low running costs or that are powered by battery, but the energy figure is determined from the power being consumed and how long this consumption takes place. If the supply voltage remains constant, then power is proportional to the current drawn by the hardware. Being able to measure current, therefore, is extremely important and enables a product’s battery life or running costs to be estimated.!!The Microchip MPLAB REAL ICE Power Monitor (AC244008) can be used with the MPLAB REAL ICE debugger, MPLAB X IDE, and MPLAB XC compilers to measure and display current and voltage versus time. This can be measured for the target board or just the device, and can be performed when the hardware is running real-world code. You can also use it to profile the current drawn for each function and to ensure that an arbitrary peak current is not exceeded.!!

Page 3: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Why Measure Power?

2

●Energy determined by power versus time ●Typically proportional to current drawn

It is actually energy consumption that is critical for embedded projects that require low running costs or that are powered by battery, but the energy figure is determined from the power being consumed and how long this consumption takes place. If the supply voltage remains constant, then power is proportional to the current drawn by the hardware. Being able to measure current, therefore, is extremely important and enables a product’s battery life or running costs to be estimated.!!The Microchip MPLAB REAL ICE Power Monitor (AC244008) can be used with the MPLAB REAL ICE debugger, MPLAB X IDE, and MPLAB XC compilers to measure and display current and voltage versus time. This can be measured for the target board or just the device, and can be performed when the hardware is running real-world code. You can also use it to profile the current drawn for each function and to ensure that an arbitrary peak current is not exceeded.!!

Page 4: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Why Measure Power?

2

Energy

●Energy determined by power versus time ●Typically proportional to current drawn

It is actually energy consumption that is critical for embedded projects that require low running costs or that are powered by battery, but the energy figure is determined from the power being consumed and how long this consumption takes place. If the supply voltage remains constant, then power is proportional to the current drawn by the hardware. Being able to measure current, therefore, is extremely important and enables a product’s battery life or running costs to be estimated.!!The Microchip MPLAB REAL ICE Power Monitor (AC244008) can be used with the MPLAB REAL ICE debugger, MPLAB X IDE, and MPLAB XC compilers to measure and display current and voltage versus time. This can be measured for the target board or just the device, and can be performed when the hardware is running real-world code. You can also use it to profile the current drawn for each function and to ensure that an arbitrary peak current is not exceeded.!!

Page 5: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Why Measure Power?

2

●Energy determined by power versus time ●Typically proportional to current drawn

●Low energy consumption leads to: ●Low running costs ●Longer battery life

It is actually energy consumption that is critical for embedded projects that require low running costs or that are powered by battery, but the energy figure is determined from the power being consumed and how long this consumption takes place. If the supply voltage remains constant, then power is proportional to the current drawn by the hardware. Being able to measure current, therefore, is extremely important and enables a product’s battery life or running costs to be estimated.!!The Microchip MPLAB REAL ICE Power Monitor (AC244008) can be used with the MPLAB REAL ICE debugger, MPLAB X IDE, and MPLAB XC compilers to measure and display current and voltage versus time. This can be measured for the target board or just the device, and can be performed when the hardware is running real-world code. You can also use it to profile the current drawn for each function and to ensure that an arbitrary peak current is not exceeded.!!

Page 6: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Why Measure Power?

2

●Energy determined by power versus time ●Typically proportional to current drawn

●Low energy consumption leads to: ●Low running costs ●Longer battery life

●Power Monitor board can provide: ●Current/voltage versus time measurements for target

board or device ●Current consumption per function ●Detection of excessive current consumption

It is actually energy consumption that is critical for embedded projects that require low running costs or that are powered by battery, but the energy figure is determined from the power being consumed and how long this consumption takes place. If the supply voltage remains constant, then power is proportional to the current drawn by the hardware. Being able to measure current, therefore, is extremely important and enables a product’s battery life or running costs to be estimated.!!The Microchip MPLAB REAL ICE Power Monitor (AC244008) can be used with the MPLAB REAL ICE debugger, MPLAB X IDE, and MPLAB XC compilers to measure and display current and voltage versus time. This can be measured for the target board or just the device, and can be performed when the hardware is running real-world code. You can also use it to profile the current drawn for each function and to ensure that an arbitrary peak current is not exceeded.!!

Page 7: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Power Monitor Connections

3

There are several connections required before you can use the Power Monitor with the MPLAB REAL ICE debugger.!!The Power Monitor board plugs in to the debugger and replaces the standard driver board, which you must first remove. The Power Monitor uses both REAL ICE connectors so you must remove any connected logic probes as well. There are several ways to connect the Power Monitor to the target board. Shown here, the modular cable is being connected. This is the simplest connection method and allows measurements of only the target board current. Connect the power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and your host PC.!!Using the modular cable from the Power Monitor to the target board is the simplest connection. The other two connection methods, tabulated here, require additional wiring to either the channel A or channel B terminal blocks on the power monitor board. These connection methods allow target board voltage to be monitored, as well as current, and can also be used to monitor the voltage and current of the actual target device rather than the entire board.!

Page 8: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Power Monitor Connections

3

●Power Monitor plugs in to the MPLAB® REAL ICE™

●Connect the Power Monitor to your target ●There are three connection methods

●Supply power to the Power Monitor ●Connect the debugger to your host PC

There are several connections required before you can use the Power Monitor with the MPLAB REAL ICE debugger.!!The Power Monitor board plugs in to the debugger and replaces the standard driver board, which you must first remove. The Power Monitor uses both REAL ICE connectors so you must remove any connected logic probes as well. There are several ways to connect the Power Monitor to the target board. Shown here, the modular cable is being connected. This is the simplest connection method and allows measurements of only the target board current. Connect the power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and your host PC.!!Using the modular cable from the Power Monitor to the target board is the simplest connection. The other two connection methods, tabulated here, require additional wiring to either the channel A or channel B terminal blocks on the power monitor board. These connection methods allow target board voltage to be monitored, as well as current, and can also be used to monitor the voltage and current of the actual target device rather than the entire board.!

Page 9: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Power Monitor Connections

3

●Power Monitor plugs in to the MPLAB® REAL ICE™

●Connect the Power Monitor to your target ●There are three connection methods

●Supply power to the Power Monitor ●Connect the debugger to your host PC

There are several connections required before you can use the Power Monitor with the MPLAB REAL ICE debugger.!!The Power Monitor board plugs in to the debugger and replaces the standard driver board, which you must first remove. The Power Monitor uses both REAL ICE connectors so you must remove any connected logic probes as well. There are several ways to connect the Power Monitor to the target board. Shown here, the modular cable is being connected. This is the simplest connection method and allows measurements of only the target board current. Connect the power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and your host PC.!!Using the modular cable from the Power Monitor to the target board is the simplest connection. The other two connection methods, tabulated here, require additional wiring to either the channel A or channel B terminal blocks on the power monitor board. These connection methods allow target board voltage to be monitored, as well as current, and can also be used to monitor the voltage and current of the actual target device rather than the entire board.!

Page 10: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Power Monitor Connections

3

●Power Monitor plugs in to the MPLAB® REAL ICE™

●Connect the Power Monitor to your target ●There are three connection methods

●Supply power to the Power Monitor ●Connect the debugger to your host PC

There are several connections required before you can use the Power Monitor with the MPLAB REAL ICE debugger.!!The Power Monitor board plugs in to the debugger and replaces the standard driver board, which you must first remove. The Power Monitor uses both REAL ICE connectors so you must remove any connected logic probes as well. There are several ways to connect the Power Monitor to the target board. Shown here, the modular cable is being connected. This is the simplest connection method and allows measurements of only the target board current. Connect the power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and your host PC.!!Using the modular cable from the Power Monitor to the target board is the simplest connection. The other two connection methods, tabulated here, require additional wiring to either the channel A or channel B terminal blocks on the power monitor board. These connection methods allow target board voltage to be monitored, as well as current, and can also be used to monitor the voltage and current of the actual target device rather than the entire board.!

Page 11: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Power Monitor Connections

3

Connection MeasurementModular (ICSP) cable Target board currentChannel A wire Target board current and/or voltageChannel B wire Target device current and/or voltage

●Power Monitor plugs in to the MPLAB® REAL ICE™

●Connect the Power Monitor to your target ●There are three connection methods

●Supply power to the Power Monitor ●Connect the debugger to your host PC

There are several connections required before you can use the Power Monitor with the MPLAB REAL ICE debugger.!!The Power Monitor board plugs in to the debugger and replaces the standard driver board, which you must first remove. The Power Monitor uses both REAL ICE connectors so you must remove any connected logic probes as well. There are several ways to connect the Power Monitor to the target board. Shown here, the modular cable is being connected. This is the simplest connection method and allows measurements of only the target board current. Connect the power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and your host PC.!!Using the modular cable from the Power Monitor to the target board is the simplest connection. The other two connection methods, tabulated here, require additional wiring to either the channel A or channel B terminal blocks on the power monitor board. These connection methods allow target board voltage to be monitored, as well as current, and can also be used to monitor the voltage and current of the actual target device rather than the entire board.!

Page 12: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Configurations

4

Before initial use of the power monitor, you must download the MPLAB X IDE Power Monitor plugin. Do this inside the IDE by selecting Plugins from the Tools menu. In the dialog, select the Available plugins tab and click the checkbox next to the Power monitor item. Click install, and follow the prompts.!!There are several selections associated with the REAL ICE and IDE that need to be made before using the power monitor. When you create your MPLAB X IDE project, it must be configured to use the REAL ICE debugger. When asked for a plugin board, select Power Monitor. Both these options can be set for existing projects from the project's properties dialog, as shown here.!!Other options need to be set in the REAL ICE category. Under the Power option, select Power target circuit from REAL ICE, and confirm the operating voltage of your target. For the first demonstration we are going to capture current versus time, so go to the Trace and Profiling option category, and for Data Collection, select Power Module. You should see the 'ready' LED on the power monitor turn green when connection is established with the debugger.!

Page 13: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Download the IDE's Power Monitor plugin

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Configurations

4

Before initial use of the power monitor, you must download the MPLAB X IDE Power Monitor plugin. Do this inside the IDE by selecting Plugins from the Tools menu. In the dialog, select the Available plugins tab and click the checkbox next to the Power monitor item. Click install, and follow the prompts.!!There are several selections associated with the REAL ICE and IDE that need to be made before using the power monitor. When you create your MPLAB X IDE project, it must be configured to use the REAL ICE debugger. When asked for a plugin board, select Power Monitor. Both these options can be set for existing projects from the project's properties dialog, as shown here.!!Other options need to be set in the REAL ICE category. Under the Power option, select Power target circuit from REAL ICE, and confirm the operating voltage of your target. For the first demonstration we are going to capture current versus time, so go to the Trace and Profiling option category, and for Data Collection, select Power Module. You should see the 'ready' LED on the power monitor turn green when connection is established with the debugger.!

Page 14: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Download the IDE's Power Monitor plugin

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Configurations

4

Before initial use of the power monitor, you must download the MPLAB X IDE Power Monitor plugin. Do this inside the IDE by selecting Plugins from the Tools menu. In the dialog, select the Available plugins tab and click the checkbox next to the Power monitor item. Click install, and follow the prompts.!!There are several selections associated with the REAL ICE and IDE that need to be made before using the power monitor. When you create your MPLAB X IDE project, it must be configured to use the REAL ICE debugger. When asked for a plugin board, select Power Monitor. Both these options can be set for existing projects from the project's properties dialog, as shown here.!!Other options need to be set in the REAL ICE category. Under the Power option, select Power target circuit from REAL ICE, and confirm the operating voltage of your target. For the first demonstration we are going to capture current versus time, so go to the Trace and Profiling option category, and for Data Collection, select Power Module. You should see the 'ready' LED on the power monitor turn green when connection is established with the debugger.!

Page 15: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Download the IDE's Power Monitor plugin●Projects must be configured to:

●Use MPLAB® REAL ICE™ debugger ●Use the Power Monitor Plugin Board ●Power target circuit from the debugger ●Use power monitor for data collection

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Configurations

4

Before initial use of the power monitor, you must download the MPLAB X IDE Power Monitor plugin. Do this inside the IDE by selecting Plugins from the Tools menu. In the dialog, select the Available plugins tab and click the checkbox next to the Power monitor item. Click install, and follow the prompts.!!There are several selections associated with the REAL ICE and IDE that need to be made before using the power monitor. When you create your MPLAB X IDE project, it must be configured to use the REAL ICE debugger. When asked for a plugin board, select Power Monitor. Both these options can be set for existing projects from the project's properties dialog, as shown here.!!Other options need to be set in the REAL ICE category. Under the Power option, select Power target circuit from REAL ICE, and confirm the operating voltage of your target. For the first demonstration we are going to capture current versus time, so go to the Trace and Profiling option category, and for Data Collection, select Power Module. You should see the 'ready' LED on the power monitor turn green when connection is established with the debugger.!

Page 16: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Download the IDE's Power Monitor plugin●Projects must be configured to:

●Use MPLAB® REAL ICE™ debugger ●Use the Power Monitor Plugin Board ●Power target circuit from the debugger ●Use power monitor for data collection

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Configurations

4

Before initial use of the power monitor, you must download the MPLAB X IDE Power Monitor plugin. Do this inside the IDE by selecting Plugins from the Tools menu. In the dialog, select the Available plugins tab and click the checkbox next to the Power monitor item. Click install, and follow the prompts.!!There are several selections associated with the REAL ICE and IDE that need to be made before using the power monitor. When you create your MPLAB X IDE project, it must be configured to use the REAL ICE debugger. When asked for a plugin board, select Power Monitor. Both these options can be set for existing projects from the project's properties dialog, as shown here.!!Other options need to be set in the REAL ICE category. Under the Power option, select Power target circuit from REAL ICE, and confirm the operating voltage of your target. For the first demonstration we are going to capture current versus time, so go to the Trace and Profiling option category, and for Data Collection, select Power Module. You should see the 'ready' LED on the power monitor turn green when connection is established with the debugger.!

Page 17: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Download the IDE's Power Monitor plugin●Projects must be configured to:

●Use MPLAB® REAL ICE™ debugger ●Use the Power Monitor Plugin Board ●Power target circuit from the debugger ●Use power monitor for data collection

●Power Monitor’s 'ready' light turns green

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Configurations

4

Before initial use of the power monitor, you must download the MPLAB X IDE Power Monitor plugin. Do this inside the IDE by selecting Plugins from the Tools menu. In the dialog, select the Available plugins tab and click the checkbox next to the Power monitor item. Click install, and follow the prompts.!!There are several selections associated with the REAL ICE and IDE that need to be made before using the power monitor. When you create your MPLAB X IDE project, it must be configured to use the REAL ICE debugger. When asked for a plugin board, select Power Monitor. Both these options can be set for existing projects from the project's properties dialog, as shown here.!!Other options need to be set in the REAL ICE category. Under the Power option, select Power target circuit from REAL ICE, and confirm the operating voltage of your target. For the first demonstration we are going to capture current versus time, so go to the Trace and Profiling option category, and for Data Collection, select Power Module. You should see the 'ready' LED on the power monitor turn green when connection is established with the debugger.!

Page 18: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Displaying Current

5

Let's now see the power monitor in action. Our project is already set up for REAL ICE and the power monitor as just shown. In this example we want to capture current versus time. Reopen the project properties dialog and the REAL ICE category; go to the Trace and Profiling option category and check that the Target Power Sampling Selection is set to Power Data Only. This indicates that current will be measured along with a time stamp. Confirm, also, the sampling interval, which is the rate at which samples will be taken.!!Open the power monitor's window from the Tools menu > Embedded > Power Monitor.!!Let's build and debug some code using the REAL ICE debugger. The code will illuminate one of the LEDs connected to a port. After each timer interrupt, the adjacent LED will also be illuminated. Once all 8 LEDs are turned on, the following interrupt will turn them all off, and the cycle repeats. A break point has been set in this code to stop after 5 iterations of this cycle. Build and debug your code in the usual way.!!Now that the code has stopped, let's look at the power monitor window to see what we captured. In this graph, current is drawn vertically against time. You can clearly see the current ramp up as more LEDs are turned on, then it drops markedly when they are all extinguished. The graph is indicating that each LED is drawing just over 1 milli amp. You can also see the period of the loop: just under 250 milli seconds.!!There are various graphing controls shown on the left of the window. You can enlarge the data display to take accurate measurements using the zoom button or a mouse gesture.!!All the breakpoints have now been removed from the code. Instead, let’s have the code break if the current exceeds a threshold value. Again, open the Trace and Profiling dialog. Note that you can get to this dialog quickly using the upper-most short-cut button on the left of this window. Enable the Break at or above Specified Current Level checkbox and enter the current threshold in the field below, in this case 20 milli amps. Let's run the code again. Execution has halted, and in the power monitor window, you can see that this has occurred when the current exceeded 20 milli amps. Execution has stopped at the line of code which wrote a value to the LEDs. As with any breakpoint, you can now check the contents of variables, such as portCount, which determines the value written to the LEDs in this example.

Page 19: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Check Trace and Profiling settings

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Displaying Current

5

Let's now see the power monitor in action. Our project is already set up for REAL ICE and the power monitor as just shown. In this example we want to capture current versus time. Reopen the project properties dialog and the REAL ICE category; go to the Trace and Profiling option category and check that the Target Power Sampling Selection is set to Power Data Only. This indicates that current will be measured along with a time stamp. Confirm, also, the sampling interval, which is the rate at which samples will be taken.!!Open the power monitor's window from the Tools menu > Embedded > Power Monitor.!!Let's build and debug some code using the REAL ICE debugger. The code will illuminate one of the LEDs connected to a port. After each timer interrupt, the adjacent LED will also be illuminated. Once all 8 LEDs are turned on, the following interrupt will turn them all off, and the cycle repeats. A break point has been set in this code to stop after 5 iterations of this cycle. Build and debug your code in the usual way.!!Now that the code has stopped, let's look at the power monitor window to see what we captured. In this graph, current is drawn vertically against time. You can clearly see the current ramp up as more LEDs are turned on, then it drops markedly when they are all extinguished. The graph is indicating that each LED is drawing just over 1 milli amp. You can also see the period of the loop: just under 250 milli seconds.!!There are various graphing controls shown on the left of the window. You can enlarge the data display to take accurate measurements using the zoom button or a mouse gesture.!!All the breakpoints have now been removed from the code. Instead, let’s have the code break if the current exceeds a threshold value. Again, open the Trace and Profiling dialog. Note that you can get to this dialog quickly using the upper-most short-cut button on the left of this window. Enable the Break at or above Specified Current Level checkbox and enter the current threshold in the field below, in this case 20 milli amps. Let's run the code again. Execution has halted, and in the power monitor window, you can see that this has occurred when the current exceeded 20 milli amps. Execution has stopped at the line of code which wrote a value to the LEDs. As with any breakpoint, you can now check the contents of variables, such as portCount, which determines the value written to the LEDs in this example.

Page 20: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Check Trace and Profiling settings●Power Data Only sampling selection:

●Power Monitor graph shows current versus time

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Displaying Current

5

Let's now see the power monitor in action. Our project is already set up for REAL ICE and the power monitor as just shown. In this example we want to capture current versus time. Reopen the project properties dialog and the REAL ICE category; go to the Trace and Profiling option category and check that the Target Power Sampling Selection is set to Power Data Only. This indicates that current will be measured along with a time stamp. Confirm, also, the sampling interval, which is the rate at which samples will be taken.!!Open the power monitor's window from the Tools menu > Embedded > Power Monitor.!!Let's build and debug some code using the REAL ICE debugger. The code will illuminate one of the LEDs connected to a port. After each timer interrupt, the adjacent LED will also be illuminated. Once all 8 LEDs are turned on, the following interrupt will turn them all off, and the cycle repeats. A break point has been set in this code to stop after 5 iterations of this cycle. Build and debug your code in the usual way.!!Now that the code has stopped, let's look at the power monitor window to see what we captured. In this graph, current is drawn vertically against time. You can clearly see the current ramp up as more LEDs are turned on, then it drops markedly when they are all extinguished. The graph is indicating that each LED is drawing just over 1 milli amp. You can also see the period of the loop: just under 250 milli seconds.!!There are various graphing controls shown on the left of the window. You can enlarge the data display to take accurate measurements using the zoom button or a mouse gesture.!!All the breakpoints have now been removed from the code. Instead, let’s have the code break if the current exceeds a threshold value. Again, open the Trace and Profiling dialog. Note that you can get to this dialog quickly using the upper-most short-cut button on the left of this window. Enable the Break at or above Specified Current Level checkbox and enter the current threshold in the field below, in this case 20 milli amps. Let's run the code again. Execution has halted, and in the power monitor window, you can see that this has occurred when the current exceeded 20 milli amps. Execution has stopped at the line of code which wrote a value to the LEDs. As with any breakpoint, you can now check the contents of variables, such as portCount, which determines the value written to the LEDs in this example.

Page 21: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Check Trace and Profiling settings●Power Data Only sampling selection:

●Power Monitor graph shows current versus timePower Data Only

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Displaying Current

5

Let's now see the power monitor in action. Our project is already set up for REAL ICE and the power monitor as just shown. In this example we want to capture current versus time. Reopen the project properties dialog and the REAL ICE category; go to the Trace and Profiling option category and check that the Target Power Sampling Selection is set to Power Data Only. This indicates that current will be measured along with a time stamp. Confirm, also, the sampling interval, which is the rate at which samples will be taken.!!Open the power monitor's window from the Tools menu > Embedded > Power Monitor.!!Let's build and debug some code using the REAL ICE debugger. The code will illuminate one of the LEDs connected to a port. After each timer interrupt, the adjacent LED will also be illuminated. Once all 8 LEDs are turned on, the following interrupt will turn them all off, and the cycle repeats. A break point has been set in this code to stop after 5 iterations of this cycle. Build and debug your code in the usual way.!!Now that the code has stopped, let's look at the power monitor window to see what we captured. In this graph, current is drawn vertically against time. You can clearly see the current ramp up as more LEDs are turned on, then it drops markedly when they are all extinguished. The graph is indicating that each LED is drawing just over 1 milli amp. You can also see the period of the loop: just under 250 milli seconds.!!There are various graphing controls shown on the left of the window. You can enlarge the data display to take accurate measurements using the zoom button or a mouse gesture.!!All the breakpoints have now been removed from the code. Instead, let’s have the code break if the current exceeds a threshold value. Again, open the Trace and Profiling dialog. Note that you can get to this dialog quickly using the upper-most short-cut button on the left of this window. Enable the Break at or above Specified Current Level checkbox and enter the current threshold in the field below, in this case 20 milli amps. Let's run the code again. Execution has halted, and in the power monitor window, you can see that this has occurred when the current exceeded 20 milli amps. Execution has stopped at the line of code which wrote a value to the LEDs. As with any breakpoint, you can now check the contents of variables, such as portCount, which determines the value written to the LEDs in this example.

Page 22: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Check Trace and Profiling settings●Power Data Only sampling selection:

●Power Monitor graph shows current versus timePower Data Only

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Displaying Current

5

Let's now see the power monitor in action. Our project is already set up for REAL ICE and the power monitor as just shown. In this example we want to capture current versus time. Reopen the project properties dialog and the REAL ICE category; go to the Trace and Profiling option category and check that the Target Power Sampling Selection is set to Power Data Only. This indicates that current will be measured along with a time stamp. Confirm, also, the sampling interval, which is the rate at which samples will be taken.!!Open the power monitor's window from the Tools menu > Embedded > Power Monitor.!!Let's build and debug some code using the REAL ICE debugger. The code will illuminate one of the LEDs connected to a port. After each timer interrupt, the adjacent LED will also be illuminated. Once all 8 LEDs are turned on, the following interrupt will turn them all off, and the cycle repeats. A break point has been set in this code to stop after 5 iterations of this cycle. Build and debug your code in the usual way.!!Now that the code has stopped, let's look at the power monitor window to see what we captured. In this graph, current is drawn vertically against time. You can clearly see the current ramp up as more LEDs are turned on, then it drops markedly when they are all extinguished. The graph is indicating that each LED is drawing just over 1 milli amp. You can also see the period of the loop: just under 250 milli seconds.!!There are various graphing controls shown on the left of the window. You can enlarge the data display to take accurate measurements using the zoom button or a mouse gesture.!!All the breakpoints have now been removed from the code. Instead, let’s have the code break if the current exceeds a threshold value. Again, open the Trace and Profiling dialog. Note that you can get to this dialog quickly using the upper-most short-cut button on the left of this window. Enable the Break at or above Specified Current Level checkbox and enter the current threshold in the field below, in this case 20 milli amps. Let's run the code again. Execution has halted, and in the power monitor window, you can see that this has occurred when the current exceeded 20 milli amps. Execution has stopped at the line of code which wrote a value to the LEDs. As with any breakpoint, you can now check the contents of variables, such as portCount, which determines the value written to the LEDs in this example.

Page 23: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Check Trace and Profiling settings●Power Data Only sampling selection:

●Power Monitor graph shows current versus time

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Displaying Current

5

Let's now see the power monitor in action. Our project is already set up for REAL ICE and the power monitor as just shown. In this example we want to capture current versus time. Reopen the project properties dialog and the REAL ICE category; go to the Trace and Profiling option category and check that the Target Power Sampling Selection is set to Power Data Only. This indicates that current will be measured along with a time stamp. Confirm, also, the sampling interval, which is the rate at which samples will be taken.!!Open the power monitor's window from the Tools menu > Embedded > Power Monitor.!!Let's build and debug some code using the REAL ICE debugger. The code will illuminate one of the LEDs connected to a port. After each timer interrupt, the adjacent LED will also be illuminated. Once all 8 LEDs are turned on, the following interrupt will turn them all off, and the cycle repeats. A break point has been set in this code to stop after 5 iterations of this cycle. Build and debug your code in the usual way.!!Now that the code has stopped, let's look at the power monitor window to see what we captured. In this graph, current is drawn vertically against time. You can clearly see the current ramp up as more LEDs are turned on, then it drops markedly when they are all extinguished. The graph is indicating that each LED is drawing just over 1 milli amp. You can also see the period of the loop: just under 250 milli seconds.!!There are various graphing controls shown on the left of the window. You can enlarge the data display to take accurate measurements using the zoom button or a mouse gesture.!!All the breakpoints have now been removed from the code. Instead, let’s have the code break if the current exceeds a threshold value. Again, open the Trace and Profiling dialog. Note that you can get to this dialog quickly using the upper-most short-cut button on the left of this window. Enable the Break at or above Specified Current Level checkbox and enter the current threshold in the field below, in this case 20 milli amps. Let's run the code again. Execution has halted, and in the power monitor window, you can see that this has occurred when the current exceeded 20 milli amps. Execution has stopped at the line of code which wrote a value to the LEDs. As with any breakpoint, you can now check the contents of variables, such as portCount, which determines the value written to the LEDs in this example.

Page 24: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Check Trace and Profiling settings●Power Data Only sampling selection:

●Power Monitor graph shows current versus time

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Displaying Current

5

Let's now see the power monitor in action. Our project is already set up for REAL ICE and the power monitor as just shown. In this example we want to capture current versus time. Reopen the project properties dialog and the REAL ICE category; go to the Trace and Profiling option category and check that the Target Power Sampling Selection is set to Power Data Only. This indicates that current will be measured along with a time stamp. Confirm, also, the sampling interval, which is the rate at which samples will be taken.!!Open the power monitor's window from the Tools menu > Embedded > Power Monitor.!!Let's build and debug some code using the REAL ICE debugger. The code will illuminate one of the LEDs connected to a port. After each timer interrupt, the adjacent LED will also be illuminated. Once all 8 LEDs are turned on, the following interrupt will turn them all off, and the cycle repeats. A break point has been set in this code to stop after 5 iterations of this cycle. Build and debug your code in the usual way.!!Now that the code has stopped, let's look at the power monitor window to see what we captured. In this graph, current is drawn vertically against time. You can clearly see the current ramp up as more LEDs are turned on, then it drops markedly when they are all extinguished. The graph is indicating that each LED is drawing just over 1 milli amp. You can also see the period of the loop: just under 250 milli seconds.!!There are various graphing controls shown on the left of the window. You can enlarge the data display to take accurate measurements using the zoom button or a mouse gesture.!!All the breakpoints have now been removed from the code. Instead, let’s have the code break if the current exceeds a threshold value. Again, open the Trace and Profiling dialog. Note that you can get to this dialog quickly using the upper-most short-cut button on the left of this window. Enable the Break at or above Specified Current Level checkbox and enter the current threshold in the field below, in this case 20 milli amps. Let's run the code again. Execution has halted, and in the power monitor window, you can see that this has occurred when the current exceeded 20 milli amps. Execution has stopped at the line of code which wrote a value to the LEDs. As with any breakpoint, you can now check the contents of variables, such as portCount, which determines the value written to the LEDs in this example.

Page 25: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Check Trace and Profiling settings●Power Data Only sampling selection:

●Power Monitor graph shows current versus time●Use a breakpoint to find when a current

threshold is exceeded

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Displaying Current

5

Let's now see the power monitor in action. Our project is already set up for REAL ICE and the power monitor as just shown. In this example we want to capture current versus time. Reopen the project properties dialog and the REAL ICE category; go to the Trace and Profiling option category and check that the Target Power Sampling Selection is set to Power Data Only. This indicates that current will be measured along with a time stamp. Confirm, also, the sampling interval, which is the rate at which samples will be taken.!!Open the power monitor's window from the Tools menu > Embedded > Power Monitor.!!Let's build and debug some code using the REAL ICE debugger. The code will illuminate one of the LEDs connected to a port. After each timer interrupt, the adjacent LED will also be illuminated. Once all 8 LEDs are turned on, the following interrupt will turn them all off, and the cycle repeats. A break point has been set in this code to stop after 5 iterations of this cycle. Build and debug your code in the usual way.!!Now that the code has stopped, let's look at the power monitor window to see what we captured. In this graph, current is drawn vertically against time. You can clearly see the current ramp up as more LEDs are turned on, then it drops markedly when they are all extinguished. The graph is indicating that each LED is drawing just over 1 milli amp. You can also see the period of the loop: just under 250 milli seconds.!!There are various graphing controls shown on the left of the window. You can enlarge the data display to take accurate measurements using the zoom button or a mouse gesture.!!All the breakpoints have now been removed from the code. Instead, let’s have the code break if the current exceeds a threshold value. Again, open the Trace and Profiling dialog. Note that you can get to this dialog quickly using the upper-most short-cut button on the left of this window. Enable the Break at or above Specified Current Level checkbox and enter the current threshold in the field below, in this case 20 milli amps. Let's run the code again. Execution has halted, and in the power monitor window, you can see that this has occurred when the current exceeded 20 milli amps. Execution has stopped at the line of code which wrote a value to the LEDs. As with any breakpoint, you can now check the contents of variables, such as portCount, which determines the value written to the LEDs in this example.

Page 26: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Code Profiling

6

Engineers face difficult challenges relating to power: Code that executes fast can quickly return the microcontroller to a low-current sleep state, but the current drawn by a microcontroller will, to some extent, be dependent on the instructions being executed. Hardware designs that minimise components also reduce the current consumption, but this choice may require additional code to compensate for the loss in functionality. How do you get the optimal energy consumption for a set of design guidelines? This is difficult to predict and requires concrete measurements. We have seen that the power monitor can reveal the current used, but how does your code affect this measurement? By using the MPLAB X IDE's code profiling feature in conjunction with the power monitor, you can assess how firmware is affecting the power consumption of a target system.!!The use the code profiling feature, reopen the REAL ICE category in the Project Properties dialog. Select Trace and Profiling and change the Target Power Sampling Selection to Power Data on PC update only. When this is selected, the Power monitor display will be updated only when certain points in your executing program are reached, specifically when the code enters and exits each function. Your MPLAB XC C compiler will automatically insert into the binary image additional code, which communicates with the power monitor so it can record when functions begin and end. You will see the code size of your project increase and, if you happen to look at the compiler-generated code, you might see additional calls to entry and exit routines.!!With code profiling enabled, I’ll now rebuild and run the same project. After I pause execution, you can see the function profiling information tabulated beneath the current and voltage graph in the Power Monitor window. The name of the function being entered is shown, along with the program counter value where the function’s entry routine is called. The name “return” is shown where the previously listed function exits. My test program is only trivial, but you can see the function main being executed, the interrupt routine being triggered repeatedly, and where each interrupt routine returns. You can see the current at each of these points in the table and how long each function takes to execute. Click any line of the table to highlight the corresponding point in the graph. Prudent use of functions in your code can reveal how your code is affecting the energy requirements of your target system.!

Page 27: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Optimal energy use entails a trade off between code and hardware

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Code Profiling

6

Engineers face difficult challenges relating to power: Code that executes fast can quickly return the microcontroller to a low-current sleep state, but the current drawn by a microcontroller will, to some extent, be dependent on the instructions being executed. Hardware designs that minimise components also reduce the current consumption, but this choice may require additional code to compensate for the loss in functionality. How do you get the optimal energy consumption for a set of design guidelines? This is difficult to predict and requires concrete measurements. We have seen that the power monitor can reveal the current used, but how does your code affect this measurement? By using the MPLAB X IDE's code profiling feature in conjunction with the power monitor, you can assess how firmware is affecting the power consumption of a target system.!!The use the code profiling feature, reopen the REAL ICE category in the Project Properties dialog. Select Trace and Profiling and change the Target Power Sampling Selection to Power Data on PC update only. When this is selected, the Power monitor display will be updated only when certain points in your executing program are reached, specifically when the code enters and exits each function. Your MPLAB XC C compiler will automatically insert into the binary image additional code, which communicates with the power monitor so it can record when functions begin and end. You will see the code size of your project increase and, if you happen to look at the compiler-generated code, you might see additional calls to entry and exit routines.!!With code profiling enabled, I’ll now rebuild and run the same project. After I pause execution, you can see the function profiling information tabulated beneath the current and voltage graph in the Power Monitor window. The name of the function being entered is shown, along with the program counter value where the function’s entry routine is called. The name “return” is shown where the previously listed function exits. My test program is only trivial, but you can see the function main being executed, the interrupt routine being triggered repeatedly, and where each interrupt routine returns. You can see the current at each of these points in the table and how long each function takes to execute. Click any line of the table to highlight the corresponding point in the graph. Prudent use of functions in your code can reveal how your code is affecting the energy requirements of your target system.!

Page 28: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Optimal energy use entails a trade off between code and hardware

●Code profiling can reveal how code affects current consumption

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Code Profiling

6

Engineers face difficult challenges relating to power: Code that executes fast can quickly return the microcontroller to a low-current sleep state, but the current drawn by a microcontroller will, to some extent, be dependent on the instructions being executed. Hardware designs that minimise components also reduce the current consumption, but this choice may require additional code to compensate for the loss in functionality. How do you get the optimal energy consumption for a set of design guidelines? This is difficult to predict and requires concrete measurements. We have seen that the power monitor can reveal the current used, but how does your code affect this measurement? By using the MPLAB X IDE's code profiling feature in conjunction with the power monitor, you can assess how firmware is affecting the power consumption of a target system.!!The use the code profiling feature, reopen the REAL ICE category in the Project Properties dialog. Select Trace and Profiling and change the Target Power Sampling Selection to Power Data on PC update only. When this is selected, the Power monitor display will be updated only when certain points in your executing program are reached, specifically when the code enters and exits each function. Your MPLAB XC C compiler will automatically insert into the binary image additional code, which communicates with the power monitor so it can record when functions begin and end. You will see the code size of your project increase and, if you happen to look at the compiler-generated code, you might see additional calls to entry and exit routines.!!With code profiling enabled, I’ll now rebuild and run the same project. After I pause execution, you can see the function profiling information tabulated beneath the current and voltage graph in the Power Monitor window. The name of the function being entered is shown, along with the program counter value where the function’s entry routine is called. The name “return” is shown where the previously listed function exits. My test program is only trivial, but you can see the function main being executed, the interrupt routine being triggered repeatedly, and where each interrupt routine returns. You can see the current at each of these points in the table and how long each function takes to execute. Click any line of the table to highlight the corresponding point in the graph. Prudent use of functions in your code can reveal how your code is affecting the energy requirements of your target system.!

Page 29: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Optimal energy use entails a trade off between code and hardware

●Code profiling can reveal how code affects current consumption

●To use code profiling:●Set Target Power Sampling to Power Data on PC

update only

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Code Profiling

6

Engineers face difficult challenges relating to power: Code that executes fast can quickly return the microcontroller to a low-current sleep state, but the current drawn by a microcontroller will, to some extent, be dependent on the instructions being executed. Hardware designs that minimise components also reduce the current consumption, but this choice may require additional code to compensate for the loss in functionality. How do you get the optimal energy consumption for a set of design guidelines? This is difficult to predict and requires concrete measurements. We have seen that the power monitor can reveal the current used, but how does your code affect this measurement? By using the MPLAB X IDE's code profiling feature in conjunction with the power monitor, you can assess how firmware is affecting the power consumption of a target system.!!The use the code profiling feature, reopen the REAL ICE category in the Project Properties dialog. Select Trace and Profiling and change the Target Power Sampling Selection to Power Data on PC update only. When this is selected, the Power monitor display will be updated only when certain points in your executing program are reached, specifically when the code enters and exits each function. Your MPLAB XC C compiler will automatically insert into the binary image additional code, which communicates with the power monitor so it can record when functions begin and end. You will see the code size of your project increase and, if you happen to look at the compiler-generated code, you might see additional calls to entry and exit routines.!!With code profiling enabled, I’ll now rebuild and run the same project. After I pause execution, you can see the function profiling information tabulated beneath the current and voltage graph in the Power Monitor window. The name of the function being entered is shown, along with the program counter value where the function’s entry routine is called. The name “return” is shown where the previously listed function exits. My test program is only trivial, but you can see the function main being executed, the interrupt routine being triggered repeatedly, and where each interrupt routine returns. You can see the current at each of these points in the table and how long each function takes to execute. Click any line of the table to highlight the corresponding point in the graph. Prudent use of functions in your code can reveal how your code is affecting the energy requirements of your target system.!

Page 30: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Optimal energy use entails a trade off between code and hardware

●Code profiling can reveal how code affects current consumption

●To use code profiling:●Set Target Power Sampling to Power Data on PC

update only

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Code Profiling

6

Engineers face difficult challenges relating to power: Code that executes fast can quickly return the microcontroller to a low-current sleep state, but the current drawn by a microcontroller will, to some extent, be dependent on the instructions being executed. Hardware designs that minimise components also reduce the current consumption, but this choice may require additional code to compensate for the loss in functionality. How do you get the optimal energy consumption for a set of design guidelines? This is difficult to predict and requires concrete measurements. We have seen that the power monitor can reveal the current used, but how does your code affect this measurement? By using the MPLAB X IDE's code profiling feature in conjunction with the power monitor, you can assess how firmware is affecting the power consumption of a target system.!!The use the code profiling feature, reopen the REAL ICE category in the Project Properties dialog. Select Trace and Profiling and change the Target Power Sampling Selection to Power Data on PC update only. When this is selected, the Power monitor display will be updated only when certain points in your executing program are reached, specifically when the code enters and exits each function. Your MPLAB XC C compiler will automatically insert into the binary image additional code, which communicates with the power monitor so it can record when functions begin and end. You will see the code size of your project increase and, if you happen to look at the compiler-generated code, you might see additional calls to entry and exit routines.!!With code profiling enabled, I’ll now rebuild and run the same project. After I pause execution, you can see the function profiling information tabulated beneath the current and voltage graph in the Power Monitor window. The name of the function being entered is shown, along with the program counter value where the function’s entry routine is called. The name “return” is shown where the previously listed function exits. My test program is only trivial, but you can see the function main being executed, the interrupt routine being triggered repeatedly, and where each interrupt routine returns. You can see the current at each of these points in the table and how long each function takes to execute. Click any line of the table to highlight the corresponding point in the graph. Prudent use of functions in your code can reveal how your code is affecting the energy requirements of your target system.!

Page 31: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Optimal energy use entails a trade off between code and hardware

●Code profiling can reveal how code affects current consumption

●To use code profiling:●Set Target Power Sampling to Power Data on PC

update only●Rebuild project and debug●Current tabulated at function entry/exit points

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Code Profiling

6

Engineers face difficult challenges relating to power: Code that executes fast can quickly return the microcontroller to a low-current sleep state, but the current drawn by a microcontroller will, to some extent, be dependent on the instructions being executed. Hardware designs that minimise components also reduce the current consumption, but this choice may require additional code to compensate for the loss in functionality. How do you get the optimal energy consumption for a set of design guidelines? This is difficult to predict and requires concrete measurements. We have seen that the power monitor can reveal the current used, but how does your code affect this measurement? By using the MPLAB X IDE's code profiling feature in conjunction with the power monitor, you can assess how firmware is affecting the power consumption of a target system.!!The use the code profiling feature, reopen the REAL ICE category in the Project Properties dialog. Select Trace and Profiling and change the Target Power Sampling Selection to Power Data on PC update only. When this is selected, the Power monitor display will be updated only when certain points in your executing program are reached, specifically when the code enters and exits each function. Your MPLAB XC C compiler will automatically insert into the binary image additional code, which communicates with the power monitor so it can record when functions begin and end. You will see the code size of your project increase and, if you happen to look at the compiler-generated code, you might see additional calls to entry and exit routines.!!With code profiling enabled, I’ll now rebuild and run the same project. After I pause execution, you can see the function profiling information tabulated beneath the current and voltage graph in the Power Monitor window. The name of the function being entered is shown, along with the program counter value where the function’s entry routine is called. The name “return” is shown where the previously listed function exits. My test program is only trivial, but you can see the function main being executed, the interrupt routine being triggered repeatedly, and where each interrupt routine returns. You can see the current at each of these points in the table and how long each function takes to execute. Click any line of the table to highlight the corresponding point in the graph. Prudent use of functions in your code can reveal how your code is affecting the energy requirements of your target system.!

Page 32: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

●Optimal energy use entails a trade off between code and hardware

●Code profiling can reveal how code affects current consumption

●To use code profiling:●Set Target Power Sampling to Power Data on PC

update only●Rebuild project and debug●Current tabulated at function entry/exit points

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Code Profiling

6

Engineers face difficult challenges relating to power: Code that executes fast can quickly return the microcontroller to a low-current sleep state, but the current drawn by a microcontroller will, to some extent, be dependent on the instructions being executed. Hardware designs that minimise components also reduce the current consumption, but this choice may require additional code to compensate for the loss in functionality. How do you get the optimal energy consumption for a set of design guidelines? This is difficult to predict and requires concrete measurements. We have seen that the power monitor can reveal the current used, but how does your code affect this measurement? By using the MPLAB X IDE's code profiling feature in conjunction with the power monitor, you can assess how firmware is affecting the power consumption of a target system.!!The use the code profiling feature, reopen the REAL ICE category in the Project Properties dialog. Select Trace and Profiling and change the Target Power Sampling Selection to Power Data on PC update only. When this is selected, the Power monitor display will be updated only when certain points in your executing program are reached, specifically when the code enters and exits each function. Your MPLAB XC C compiler will automatically insert into the binary image additional code, which communicates with the power monitor so it can record when functions begin and end. You will see the code size of your project increase and, if you happen to look at the compiler-generated code, you might see additional calls to entry and exit routines.!!With code profiling enabled, I’ll now rebuild and run the same project. After I pause execution, you can see the function profiling information tabulated beneath the current and voltage graph in the Power Monitor window. The name of the function being entered is shown, along with the program counter value where the function’s entry routine is called. The name “return” is shown where the previously listed function exits. My test program is only trivial, but you can see the function main being executed, the interrupt routine being triggered repeatedly, and where each interrupt routine returns. You can see the current at each of these points in the table and how long each function takes to execute. Click any line of the table to highlight the corresponding point in the graph. Prudent use of functions in your code can reveal how your code is affecting the energy requirements of your target system.!

Page 33: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Conclusion

7

In this webinar we have seen that the MPLAB REAL ICE Power Monitor board is a valuable tool for projects that have power constraints. It can display current-voltage plots revealing your hardware’s rate of energy consumption. Current-threshold breakpoints and code profiling allow you to determine which parts of your program draw excessive current. The Power Monitor is compatible with the current versions of MPLAB X IDE and all MPLAB XC C compilers, and can be used with all PIC devices.

Page 34: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Conclusion

●MPLAB® REAL ICE™ Power Monitor can: ●Quantify current and voltage ●Measure either target board or device

7

In this webinar we have seen that the MPLAB REAL ICE Power Monitor board is a valuable tool for projects that have power constraints. It can display current-voltage plots revealing your hardware’s rate of energy consumption. Current-threshold breakpoints and code profiling allow you to determine which parts of your program draw excessive current. The Power Monitor is compatible with the current versions of MPLAB X IDE and all MPLAB XC C compilers, and can be used with all PIC devices.

Page 35: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Conclusion

●MPLAB® REAL ICE™ Power Monitor can: ●Quantify current and voltage ●Measure either target board or device

●MPLAB® X IDE Power Monitor plugin can: ●Display current versus time graphs ●Break code execution on current threshold ●Profile function’s use of power

7

In this webinar we have seen that the MPLAB REAL ICE Power Monitor board is a valuable tool for projects that have power constraints. It can display current-voltage plots revealing your hardware’s rate of energy consumption. Current-threshold breakpoints and code profiling allow you to determine which parts of your program draw excessive current. The Power Monitor is compatible with the current versions of MPLAB X IDE and all MPLAB XC C compilers, and can be used with all PIC devices.

Page 36: The Quest For Power - Microchip Technology€¦ · The Quest For Power ... power supply to the power monitor board and ensure the REAL ICE USB cable is connected to the debugger and

© 2014 Microchip Technology Incorporated. All Rights Reserved. The Quest For Power Slide

Conclusion

●MPLAB® REAL ICE™ Power Monitor can: ●Quantify current and voltage ●Measure either target board or device

●MPLAB® X IDE Power Monitor plugin can: ●Display current versus time graphs ●Break code execution on current threshold ●Profile function’s use of power

●Compatible with all MPLAB® XC C compilers and all Microchip PIC® microcontrollers

7

In this webinar we have seen that the MPLAB REAL ICE Power Monitor board is a valuable tool for projects that have power constraints. It can display current-voltage plots revealing your hardware’s rate of energy consumption. Current-threshold breakpoints and code profiling allow you to determine which parts of your program draw excessive current. The Power Monitor is compatible with the current versions of MPLAB X IDE and all MPLAB XC C compilers, and can be used with all PIC devices.