3.1 Active Mode Implementation Example on PIC32CM PL10
In the Active mode implementation, the CPU remains in Active mode throughout operation. A Real-Time Counter (RTC) compare interrupt fires every 100 ms and sets a software flag. The main loop busy-waits on this flag to trigger each ambient light sensor sampling cycle. The CPU then power up the sensor through General-Purpose Input/Output (GPIO), busy-waits for a 10 ms warm-up period (polling a Timer/Counter 1 (TC1) overflow flag), collects 16 software-triggered Analog-to-Digital Converter (ADC) samples, averages the results, and transmits data through Universal Asynchronous Receiver/Transmitter (UART) when the averaged value exceeds a threshold (1500).
In this implementation, the CPU is active for the following operations:
- Busy-waiting on the RTC interrupt flag between 100 ms sampling cycles
- Powering up the light sensor (GPIO control)
- Busy-waiting during the 10 ms sensor warm-up (polling TC1 overflow flag)
- Starting each ADC conversion through software trigger and polling for completion
- Processing 16 ADC samples and calculating the average
- Conditionally transmitting data through UART at 230400 baud
The power consumption for the Active mode sequence was measured using the Atmel Power Debugger and captured with the MPLAB® Data Visualizer, as shown in the following figure.
The waveform shows a nearly constant current draw throughout the entire measurement window. The Power Analysis reports an average of 6.18 mA, a minimum of 6.15 mA, and brief peaks of 6.35 mA during ADC sampling and UART transmission bursts. These peaks are barely distinguishable from the baseline because the CPU's continuous Active mode draw at 24 MHz dominates the overall power consumption, resulting in an average power of approximately 18.3 mW. Critically, there is no reduction in current draw during the 10 ms sensor warm-up delay or the idle periods between 100 ms sampling cycles, the CPU consumes the same current regardless of whether useful computation is occurring. This flat profile establishes the 6.18 mA Active mode figure as the baseline for all power reduction comparisons in this document.
