# An Energy-Efficient Strategy for Microcontrollers
## 4 Experiments and Results
### Processor Clock Frequencies and Energy Consumption  
The STM32F407 processor used as target hardware has an adjustable processor clock frequency of up to 168 MHz. In this subsection, the only variable is the processor clock frequency. Each test case is compiled with the exact same compiler optimization options and executed at different processor clock frequencies. The working current, execution time, and energy consumption under these circumstances are collected and compared. The working current of the microcontroller itself in Figure 5 shows an almost perfect linear increment with the processor clock frequency, and the approximate fitted line is  
\[\text{I(mA)}=0.2509\times\text{f(MHz)},\text{R}^{2}=0.9961 \tag{15}\]  
According to STMicroelectronics' website, the working current of the STM32F407 processor is approximately 238 \(\upmu\)A/MHz, and our result is consistent with the data provided by the chip vendor. Figure 5 also shows the execution time of a typical test case at different processor clock frequencies. The execution time decreases as the processor clock frequency increases, and it exhibits an inverse proportional relationship. The energy consumption of the microcontroller itself can be obtained by combining the execution time and the working current. Figure 6 shows the energy consumed by the microcontroller itself of a test case  
Figure 4: Connection diagram of the measuring platform. Figure 5: The relation between the execution time, the working current of the microcontroller itself, and the processor clock frequency. at different processor clock frequencies. Although the working current increases with an increase in the processor clock frequency, the execution time is shortened with an increase in the processor clock frequency. As a result, the energy consumption of the microcontroller itself is hardly related to the processor clock frequency based on this test. The energy consumption of the microcontroller itself can be approximately calculated by  
\[\text{E}=\text{U}\times\text{I}\times\text{t}=5.000\text{V}\times(0.2509\times \text{f})\times(148.77\times\text{f}^{-1.005})=186.632\times\text{f}^{-0.005} \tag{16}\]  
As mentioned in Section 3.1, the existence of peripheral components in actual applications is inevitable. Figures 7 and 8 show the execution time, the working current, and the energy consumption of the whole system. Figure 6: The relation between the energy consumption of the microcontroller itself, the processor clock frequency, and the working current. Figure 7: The relation between the execution time, the working current of the whole core board, and the processor frequency. It can be seen that, for the whole core board, the working current and the processor clock frequency still show a linear increment. Further, the slope, which is the working current per MHz processor clock frequency, is very close to that of the microcontroller itself. It can be concluded that the working current of the peripheral components on the core board will remain at a stable value regardless of how the processor clock frequency changes. Thus, the power consumption of peripheral components is a relatively constant value. The energy consumption of the whole system can be approximately calculated by  
\[\text{E}=\text{U}\times\text{I}\times\text{t}=5.000\text{V}\times(0.2428\times \text{f}+9.0039)\times(148.77\times\text{f}^{-1.005})=180.607\times\text{f}^{- 0.005}+6697.551\times\text{f}^{-1.005} \tag{17}\]  
It can be seen that Equation (17) is monotonically decreasing. In this case, the energy consumption of the system consists of two parts: the energy consumed by the microcontroller itself and the energy consumed by the peripheral components. The peripheral component consumed an electric current of approximately 9 mA.