Low-Power Application on SAM D21 Using MPLAB® Harmony v3 Peripheral Libraries: Step 7

Last modified by Microchip on 2024/09/16 10:25

Build and Program the Application

Clean and build your application by clicking on the Clean and Build button.

In case of compilation errors, recheck the steps and build the project again.

Back to Top


Program your application to the device by clicking on the Make and Program button.

Back to Top


Open the Tera Term application (or another terminal console) on your PC and navigate to File > New connection...

Tera Term File > New connection...

Figure 1

Back to Top


Navigate to the Serial box in the opened window and select the corresponding Embedded Debugger (EDGB) Virtual COM Port port number of your connected SAM D21 Xplained Pro Evaluation Kit. Press OK to open a serial connection.

Tera Term New Connection window Port selection

Figure 2

Back to Top


Navigate to Setup > Serial port... to open the Serial port configuration of Tera Term.

Serial port configuration of Tera Term

Figure 3

Back to Top


In the Serial Port window, verify that the Baud rate is set to 4800 and other elements are set as shown in the accompanying image, then press OK.

Tera Term Serial Port setup window

Figure 4

Back to Top


Now that the serial console is configured, reset the board, and verify the application displayed the Measurement Menu along with the application title message.

Console message after reset

Figure 5

Make sure to keep the complete hardware setup or the light sensor on the I/O1 Xplained Pro board under proper lighting when testing the application, this will help to wake up the device when you cover the light sensor.

Back to Top


Select the Power Measurement Mode by entering option "a".

Result Screen 1

Figure 6

Cover the light sensor on the IO Xplained Pro board (by placing your hand over it - keep your finger above(1cm) the sensor to print the temperature on the terminal and remove the hand. Repeat this step to continue printing the temperature on the terminal.

Result Screen 2

Figure 7

You should see the temperature values (in °F) getting printed on the terminal when the light sensor is covered, as shown in Figure 7.

Back to Top

Observe Current Consumption on Data Visualizer

Data Visualizer is a program to process and visualize data. The Data Visualizer can receive data from various sources such as the Embedded Debugger Data Gateway Interface (EDBG DGI) and COM ports. It is possible to track an application in run-time using a terminal graph or oscilloscope. It analyzes the power consumption of an application through a correlation of code execution and power consumption when used together with a supported probe or board.

Download and install the stand-alone Data Visualizer.

Before measuring the power consumption, power on reset the device, then select the Power Measurement Mode by entering option "a" on the Serial terminal.

Open the Data Visualizer application from your PC. Select the connected Power Debugger Data Gateway board on the DGI Control Panel. Then, click Connect.

The Data Visualizer will then start searching for protocols from the Power Debugger board.

DGI Control Panel

Figure 8

 ​

Back to Top


Once the Data Visualizer is connected to the Power Debugger, different interfaces will appear. Select the Power interface and click on the Start button to start measuring the power consumption of the device.

Power Interface Start Button

Figure 9

Ensure that the hardware setup is connected as mentioned in the Hardware Setup on the launch page.

On the right-hand side of the Power Analysis window, click on the Control Panel tab and disable Channel B.

Power Analysis Window

Figure 10

Back to Top


Figure 11 shows the device in Standby mode with its measured power consumption. You can observe small peaks that illustrate the 500 milliseconds Real-Time Clock (RTC) timer expiry.

device in Standby mode with its measured power consumption

Figure 11

The average value is considered when measuring the power consumption of the device because the instant value is not stable. Then, the power consumption of the device in Standby mode is 5.9 µA.

Back to Top


Cover the light sensor on the I/O1 Xplained Pro board by placing your hand over it (or another element) to print the temperature on the terminal and observe the power consumption of the device.

Power Analysis window power consumption of the device

Figure 12

The power consumption of the device in Active mode is 11.3 mA and the power consumption of the same device in Standby mode is 5.6 µA (instant value). This shows the device in Standby mode will consume less power.

The message in Figure 13 is printed on the serial terminal when you have done this step.

Result Screen 3

Figure 13

Back to Top


Press the SW0 button to switch from Standby mode to Idle mode. Figure 14 shows the transition of the power consumption from Standby Sleep mode to Idle Sleep mode.

Active Idle Transition

Figure 14

The power consumption of the device in Standby Sleep mode is in µA and the power consumption of the same device in Idle Sleep mode is ~2.7 mA. This shows the device in Idle Sleep mode will consume a little higher power than Standby Sleep mode.

The message in Figure 15 is printed on the serial terminal when you have done this step.

Result Screen 4

Figure 15

Back to Top


Place your hand close to the light sensor. The device wakes up, reads, and prints temperature values on the serial console, and re-enters the Standby mode. Figure 16 shows the transition power consumption values from Idle to Standby mode.

Idle to Standby mode

Figure 16

The message in Figure 17 is printed on the serial terminal when you have done this step.

Result Screen 5

Figure 17

Figure 18 shows the device in Idle mode with a measured power consumption of 2680 µA.

Idle mode

Figure 18

You can observe that the small peaks coming from the RTC timer expiry disappeared because the power consumption in Idle mode is higher than the power required to start AC conversion.

Note that the above results highlight that the power consumption is lower in Standby mode than in Idle mode.  

Back to Top

Wake-up Time Measurement Using Logic Analyzer/Cathode-Ray Oscilloscope (CRO)

To demonstrate the CPU wake-up time, switch SW0 is configured to generate an interrupt. A General Purpose Input/Output (GPIO) is toggled in the Interrupt Service Routine (ISR) of the switch press event. The MCU comes out of Sleep mode when an interrupt occurs (in this case, the switch press interrupt). The time between the switch press and the GPIO toggle in the ISR is the wake-up time.

Before measuring the Wake-up Time, power on reset the device and select the Wake-up Time Measurement mode by entering option "b" on the Serial terminal.

Connect your Logic Analyzer or your CRO to the board as mentioned in Hardware Setup on the Launch Page.

Back to Top


Now, press the SW0 switch and capture the signals to measure the wake-up time from Standby Sleep to Active.

Figure 19 shows the wake-up time for the device Standby Sleep mode to Active mode:

wake-up time for the device Standby Sleep mode to Active mode

Figure 19

The message in Figure 20 is printed on the serial terminal when you have done this step.

Result Screen 6

Figure 20

Press the SW0 switch and capture the signals to measure the wake-up time from Idle Sleep to Active.

Figure 21 shows the wake-up time for the device Idle Sleep mode to Active mode:

wake-up time for the device Idle Sleep mode to Active mode

Figure 21

The message in Figure 22 is printed on the serial terminal when you have done this step.

Result Screen 7

Figure 22

When you repeat pressing SW0, the device sleep state will switch between Standby to Idle and Idle to Standby.

The message in Figure 23 is printed on the serial terminal when you have done this step.

Result Screen 8

Figure 23

By observing the outputs, you can conclude that the wake-up time is greater in Standby mode than in Idle mode.

Back to Top

Results

You successfully created a low-power application using the SAM D21 Xplained Pro Evaluation Kit and I/O1 Xplained Pro Kit and experienced how, where, and which Low Power mode to use depending on the application requirements such as power and wake-up response times.

Analysis

In this lab, you have successfully created a project from scratch, added Peripheral Libraries (PLIBs), and learned how to use an Event System to drive events received from the peripherals without CPU intervention. You also learned how to configure a device to work in Sleep modes and measure wake-up time.

Conclusions

In this tutorial, you discovered how to configure the device to work in Sleep modes. This tutorial can be used as a reference when you develop a real-time application where the power and wake-up response time play crucial roles.

Back to Top