STM32L010で節電の為に4MHzにする。(内部電圧1.5V) HAL
目的
節電化
#include "mbed.h"
void s_clk4();
DigitalOut myled(PA_4); RawSerial pc(PA_2, PA_3); //010 tx, rx
int main()
{
//__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);//4Mhz 1.8
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);//4Mhz 1.5 560uA
//__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);//4Mhz 1.2 460uA W_Not_Flash
s_clk4();
pc.baud(9600); //16mz
//printf("%d Hz\r\n", SystemCoreClock);
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
printf("%d Hz\r\n", SystemCoreClock);
}//while
}//main
void s_clk4()
{
/*4mz*/
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV4;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);
}//s_clk4
Author And Source
この問題について(STM32L010で節電の為に4MHzにする。(内部電圧1.5V) HAL), 我々は、より多くの情報をここで見つけました https://qiita.com/caa45040/items/5de88bebf975b9795390著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .