Compute cpu load for a STM32L0, a gpio and a voltmeter
Hello,
At work we have developed firmware on a stm32l0 based on different time base with systick and counters of elapsed time (10ms, 100ms and 1s). Therefore, some function are executed periodically.
The board is powered with 3.3V.
In order to measure cpu load, we use a gpio and a voltmeter as below :
main()
{
/* Init phases */
...
...
while(1)
{
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_12,GPIO_PIN_RESET);
if(u8_FlagTime10ms == 1u)
{
u8_FlagTime10ms = 0u;
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_12,GPIO_PIN_SET);
/*
* Do some stuff
*/
}
if(u8_FlagTime100ms == 1u)
{
u8_FlagTime100ms = 0u;
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_12,GPIO_PIN_SET);
/*
* Do some stuff
*/
}
if(u8_FlagTime1000ms == 1u)
{
u8_FlagTime1000ms = 0u;
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_12,GPIO_PIN_SET);
/*
* Do some stuff
*/
}
}
}In this way, by using the min, max and average value shown by the voltmeter, we can compute the cpu load with the formula :
Cpu load % min = ( (3.3V - V_min_voltmeter) / 3.3V ) * 100
Cpu load % moy = ( (3.3V - V_moy_voltmeter) / 3.3V ) * 100
Cpu load % max = ( (3.3V - V_max_voltmeter) / 3.3V ) * 100
My question is the following:
Is this method suitable to compute cpu load for an stm32L0 ?
Thank you in advance :smiling_face_with_smiling_eyes:
Sebastian