1 Concept

Low-power applications are designed to operate with minimal power consumption while still providing the required functionality. This is achieved using advanced power management techniques, such as power gating, voltage scaling and clock gating. These techniques allow the device to operate in low-power modes when not in use, reducing power consumption and extending battery life.

The Low-Frequency Internal Oscillator (LFINTOSC) an oscillator that generates a clock signal with low frequency, typically calibrated to 32 kHz. This oscillator is important in low-power applications because it has minimal power consumption compared to other oscillators. LFINTOSC is often used as a clock source for low-power modes, such as Sleep or Standby mode. By using LFINTOSC instead of a higher frequency oscillator, the microcontroller can optimize power usage and extend its battery life.

The three instances of the application were benchmarked using Microchip's Power Debugger and a PIC18F56Q71 Curiosity Nano board. The channel A ammeter of the Power Debugger was connected to the Curiosity Nano board to measure current. The output pin of the MCP9700 was connected to the RA4 pin of the Curiosity Nano board. Figure 1-1 depicts the setup for the three application variants.

Figure 1-1. Hardware Connections for Current Measurements
Important: Cut the Target Power strap (J101) for Current measurement, and attach the Power Debugger's ammeter probes to the two terminals of J101. Refer to the PIC18F56Q71 Curiosity Nano User’s Guide for more information about Low-Power measurement.
Figure 1-2. Target Power Strap Placement on the Curiosity Nano Board

This application note presents one of the most significant characteristics of the APM peripheral - the capability to allow analog modules to be switched on and off without core interaction using the APM internal timer. Figures 2-3 and 2-4 offer an overview of the peripherals utilized to drive the MCP9700 sensor and acquire data in all three application variants.

Figure 1-3. Ambient Temperature Basic Application Peripherals
Figure 1-4. Ambient Temperature Basic Application with APM

This example is designed to periodically read the ambient temperature using the MCP9700 Linear Active Thermistor ICs sensor, whose output voltage is directly proportional to the measured temperature values ranging from -40°C to +150°C. The obtained data is then transmitted via the Universal Asynchronous Receiver Transmitter (UART) module to MPLAB® Data Visualizer. This sensor is driven using the integrated 10-bit DAC module with the sensor’s lowest accepted operating voltage. According to the sensor's data sheet, the sensor operating current is between 5 and 12 µA, well below the maximum current of 50 mA, which a pin can supply. The output voltage is connected to the positive input of the OPA module used in a noninverting configuration with a 2.67 gain. The output of the OPA is connected internally to Context 1 of the ADC with Computation and Context Switching module, which is configured in Average mode as the Operating Mode. This mode allows the MCU to accumulate eight values in eight seconds, then return the averaged value that will be converted to a representation of the ambient temperature in degrees Celsius readable via the UART module.

The first application example uses the Universal Timer (UTMR) module to manage the timings. It is configured to trigger an auto-conversion of the ADC every one second. After eight consecutive conversions of the ADC with accumulation, the ADC triggers an interrupt to return the averaged result. Then, the ambient temperature is processed and printed to the terminal using the UART module. One period is described by all the eight consecutive ADC conversions, computing and sending the ambient temperature to the terminal. This example results in a higher power consumption, as all modules remain on at all times except for the UART module. Refer to the Application Examples Benchmarking section for more information about current measurements.

The second application example uses the APM module to define the timings, configured as an auto-conversion trigger source for the ADC every one second. This scenario differs from the first application due to the fact that the used analog modules are switched on and off periodically, without any software intervention, with the purpose of the application being the same as the first one. The usage of the APM in this example presents a significant reduction in current consumption. Refer to the Application Examples Benchmarking section for more information about current measurements.

The last application example is very similar to the second example, but differs by using Sleep mode as a power-saving method provided by PIC® MCUs. Sleep mode gives the best power savings because the CPU and the selected peripherals stop operation. However, some peripheral clocks proceed to operate during Sleep, such as LFINTOSC, the High-Frequency Internal Oscillator (HFINTOSC) and the Analog-to-Digital Converter RC Oscillator (ADCRC). The peripherals using those clocks also continue to operate. In this mode, no conversion of the ADC will wake up the core, which will only be used at the last conversion to return the averaged result that will be processed and printed via UART. By incorporating Sleep mode, this variation of the example demonstrates the highest level of power efficiency. Refer to the Application Examples Benchmarking section for more information about current measurements.

Figure 1-5 shows the logical flow of the applications.

Figure 1-5. Logical Flow Diagram

All three application examples use small, fixed periods for a simple and comprehensive presentation. The benchmarking period is eight seconds long. During this period, eight ADC conversions are accumulated, followed by printing the average ADC value using UART. The APM period can be set up to a maximum of 38 hours, meaning the application can be designed to use less power.

The software project is built using two types of functions, those generated with MPLAB® Code Configurator (MCC) and custom application functions, such as:

  • ADC_UserContext1Callback - sets a flag when the ADC interrupt is generated
  • ClearADCFlag - clears the flag set by the previous function
  • TemperatureProcessing - processes the temperature. It retrieves the averaged value from eight repeated ADC conversions every one second. The value is represented by the ADC-specific interrupt and processed using the ADC formula to determine the input voltage applied on the pin and stored in the inputADCVoltage variable. Next, it is computed using the specific formula for the MCP9700 sensor, described in its respective data sheet. In the final stage of the cycle, the value stored in the calculatedTemperature variable represents the argument of the PrintTemperature function.
  • PrintTemperature - enables the UART communication, sends the specific text and value to the terminal, waits until the transmission is done and disables UART to reduce the necessary power

The infinite while() loop checks if the ADC conversions are finalized and then computes and prints the temperature.

 while(1)
    {
        if(adcContext1Flag)
        {
            TemperatureProcessing();

            ClearADCFlag();
        }
    }