A Glimpse at C-States and System on Chip (SoC) Watch on the Intel® Quark™ Microcontroller D2000

ID 733326
Updated 12/31/2016
Version Latest
Public

author-image

By

Overview

This post discusses how to:

  • Browse Power_Profiler, a code example built in the Intel® System Studio for Microcontrollers.
  • Review c-states for the Intel® Quark™ microcontroller D2000 (this example uses the 2017 Intel System Studio for Microcontrollers, update 1).
  • Use the Soc Watch tool for profiling.

Prerequisite

To better understand this article and example, we recommend that you already have experience using the Intel System Studio for Microcontrollers to build example code. If you don't have experience, you can get it with this tutorial: Intel Quark Microcontroller Developer Kit D2000 for Accelerometer and Pulse Width Modulation (PWM).

Tools

You can purchase the Intel Quark microcontroller D2000 development board from a global hardware distributor's online store, then start to play with this default integrated development environment (IDE) software on your own. Even without the hardware, you can still browse the board support package (BSP) for the Intel® Quark™ microcontroller D2000. To do so, download the developer IDE software: the Intel System Studio for Microcontrollers, which contains the Intel Quark microcontroller D2000, BSPs for Intel® Quark™ SE, compiler, OpenOCD debugger, and more. Download the Software.

This example uses the Intel System Studio for Microcontrollers 2017 update 1.

Create a Power_Profiler Project

 

  1. In the IDE, select File > New > Intel Project for Microcontrollers. The Create a New Project dialog box appears.
  2. In Name, type the project's name.
  3. Under Examples, click Power > Power Profiler.
  4.  Click Finish. This creates a Power_Profiler example project, as shown in the image below. You can build this project and flash it to the development board.

C-States Revealed in Power_Profiler

Power_Profiler performs a test to iteratively enter different low-power (sleep) states, defined in power_states.c. The real time clock (RTC) interrupt event is also set to wake the system from these sleep states every 500 ms (or shorter) with an LED blink signal.

According to the Intel Quark SE microcontroller BSP for the Intel® Quark™ Microcontroller Software Interface (Intel® QMSI) 1.1 in the 2017 version of Intel System Studio for Microcontrollers (update 1), the power states for Intel Quark Microcontroller D2000 power states can be categorized as follows.

  • C0 (Active): Makes the  processor run at 32 MHz (normal speed). You can lower the operation speed to a minimum of 4 MHz, which consumes lower power.
  • C1 (halt): Puts the processor into sleep mode, consuming less power than C0. Various interrupts can wake up the system.
  • C2 (sleep): Puts the microcontroller into sleep mode and turns down most of the peripherals (SPI, UART, I2C, PWM). Few limited interrupts (RTC, GPIO, and comparator) can wake up the system.
  • C2LP (deep sleep): Turns off all peripherals and shuts down ADC. Only the GPIO setup comparator can wake up the system. It takes a longer latency to return to C0 Active.

    You can find function details regarding which components are shut down or are put into low power mode in power_states.c by following the code snippets, below:

//main.c
#define ENTER_C1() power_cpu_halt()
#define ENTER_C2() power_soc_sleep()
#define ENTER_C2LP() power_soc_deep_sleep()

Intel Quark microcontroller D2000 supports four system root clock frequencies of 4, 8, 16, and 32 MHz. Eight clock dividers allow you to lower the frequency to about 128 kHz to optimize the power usage. Plus, it allows the possibility of running the entire SoC at a minimum of 32.768 kHz as a working frequency for ultra-low power usage. Switch the frequency using the following code snippets:

clk_sys_set_mode(CLK_SYS_CRYSTAL_OSC, CLK_SYS_DIV_8);//4Mhz

clk_sys_set_mode(CLK_SYS_CRYSTAL_OSC, CLK_SYS_DIV_4);//8Mhz

clk_sys_set_mode(CLK_SYS_CRYSTAL_OSC, CLK_SYS_DIV_2);//16Mhz

clk_sys_set_mode(CLK_SYS_CRYSTAL_OSC, CLK_SYS_DIV_1);//32Mhz

clk_sys_set_mode(CLK_SYS_RTC_OSC, CLK_SYS_DIV_1);//32.768khz

What is the Purpose of the SOC_WATCH_LOG_EVENT Macro?

You may be curious about where the profiler part is located. If you are familiar with Intel System Studio, you may be aware of the SoCWatch tool, which is used to collect power-related metrics for platforms with Intel® architecture of both client and server segments. This SoC Watch keyword happens to be in the RTC interrupt callback function of the below code example, which uses the SOC_WATCH_LOG_EVENT macro to record events:

void rtc_example_callback(void)
{
      /* Log the interrupt event */
      SOC_WATCH_LOG_EVENT(SOCW_EVENT_INTERRUPT, QM_IRQ_RTC_0_VECTOR);

Once you look into the soc_watch_log_app_event, notice that the event logs are stored in one data structure: <sw_profiling_event_buffer>. How we can use it for profiling? It’s an open question. We need to wait for a future release of the Power Profiler tool.

References

Intel Quark Microcontroller D2000: Datasheet in the Intel Quark Microcontroller D2000 Documentation

Intel Quark Microcontroller Developer Kit D2000 Accelerometer and PWM: Lab Guide