Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 6 months ago.
Trying to achive ultra low power in STM32L053R8
Hello all, I'm trying to see ultra low power consumption in my custom board(STM32l053r8). I'm not using external oscillator. I just generated code from STM32cubeMX. The settings i made are HSI clock with division factor of 8. i.e.2MHZ to all.
I simply added systemclockconfig function to a simple mbed code. I could see the power differences. When i use division 1 my board consumes 4.8mA (16MHZ) division 2 it is 3.7mA (8MHZ) division4 it is 3.1mA division 8 it is 2.88mA 2.8mA is toomuch. my code is :
#include "stm32l0xx_hal.h" #include "mbed.h" Serial pc(D8,D2); void setup(void) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; __PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = 16; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; HAL_RCC_OscConfig(&RCC_OscInitStruct); RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV8; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0); HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); }; int main() { pc.baud(115200); setup(); while(1) { pc.printf(" hello"); } }
After i run above program I could not able to print that hello. Whats the wrong here. How can i achieve ultra low power by configuring HSI clock. Is this correct way of setting HSI clock?.
Thank you one and all.
1 Answer
8 years, 6 months ago.
Without checking your clock code, first run the setup code, then set the baudrate. Now for the baudrate it sets dividers dependent on the clock, but then you change the clock, so the dividers are wrong. Also I would start with a lower baudrate, this is quite high with such a slow clock.
Dear Erik, thank you for your reply.
int main() { setup(); pc.baud(9600); while(1) { pc.printf(" hello"); } }
I have changed the main function like above. First i run the setup code, then set the baud rate. Unfortunatly no data on serial terminal.
Without checking your clock code, first run the setup code, then set the baudrate. from your above statement.. Without checking your clock code means??.
posted by 21 Jun 2016It means he hasn't checked your setup code to verify that you are setting the clocks correctly.
posted by 21 Jun 2016/* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
when i remove above interrupt from setup() function then ticker objects are working. But if i use that nothing working. Also statements below wait(1); are not executing. I have tried many baudrates but no resukt with pc.print.
posted by 21 Jun 2016Given that you don't have an external clock I assume that you are using the regular USART, correct? If you're trying to minimize power consumption, have you considered adding a low speed external clock such as a 32.768 kHz crystal to make use of the LPUART? Take a look at Table 38. (Peripheral current consumption in Run or Sleep mode) of the STM32L053R8 spec sheet. LPUART draws nearly half the current of USART. In fact if you're using the Nucleo board, I believe it already has the necessary crystal. You'd be able to turn off the high speed clock to help reduce power consumption as well which should help get you within the range you're looking for.
posted by 23 Jun 2016