当前位置:网站首页>Weidongshan Internet of things learning lesson 1
Weidongshan Internet of things learning lesson 1
2022-07-05 08:12:00 【qq_ forty-one million seven hundred and forty-four thousand fou】
I reviewed it again today STM32 Internet of things programming for . Mainly review the past STM32 Clock settings for , And put notes :
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0}; // hold RCC_OscInitStruct The variable is cleared .
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; // hold RCC_ClkInitStruct The variable is cleared .
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; // Clock type
/*
#define RCC_OSCILLATORTYPE_NONE 0x00000000U // No clock
#define RCC_OSCILLATORTYPE_HSE 0x00000001U // Use the external oscillator crystal oscillator as the clock
#define RCC_OSCILLATORTYPE_HSI 0x00000002U // Use internal high-speed clock , The clock frequency is 8MHz
#define RCC_OSCILLATORTYPE_LSE 0x00000004U // Use an external low-speed clock , The clock frequency is 32.768kHZ
#define RCC_OSCILLATORTYPE_LSI 0x00000008U // Internal low-power sleep clock , The frequency is 30~60Hz
*/
RCC_OscInitStruct.HSEState = RCC_HSE_OFF; // Turn off the clock when the external crystal oscillator is not used , Open it when you need it .
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
/* One function is to empty HSE frequency division , initialization HSE frequency division ; You can also rewrite RCC_HSE_PREDIV_DIV1,
Rewrite directly RCC_CFGR Register value , But it's useless. Later, it will be changed back by the later code , So it usually doesn't move here .*/
RCC_OscInitStruct.HSIState = RCC_HSI_ON; // If you use an internal clock , Just turn it on , Close it before you use it .
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; // Turn on the PLL , Close the PLL without frequency division
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
/*
If it is RCC_PLLSOURCE_HSI_DIV2, The PLL uses the internal clock as the benchmark , Frequency is 8MHZ After dichotomy, it becomes 4MHz.
If it is RCC_PLLSOURCE_HSE, The PLL uses the external clock as the reference , The frequency is the external clock frequency
*/
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
/*
#define RCC_PLL_MUL2 RCC_CFGR_PLLMULL2
#define RCC_PLL_MUL3 RCC_CFGR_PLLMULL3
#define RCC_PLL_MUL4 RCC_CFGR_PLLMULL4
#define RCC_PLL_MUL5 RCC_CFGR_PLLMULL5
#define RCC_PLL_MUL6 RCC_CFGR_PLLMULL6
#define RCC_PLL_MUL7 RCC_CFGR_PLLMULL7
#define RCC_PLL_MUL8 RCC_CFGR_PLLMULL8
#define RCC_PLL_MUL9 RCC_CFGR_PLLMULL9
#define RCC_PLL_MUL10 RCC_CFGR_PLLMULL10
#define RCC_PLL_MUL11 RCC_CFGR_PLLMULL11
#define RCC_PLL_MUL12 RCC_CFGR_PLLMULL12
#define RCC_PLL_MUL13 RCC_CFGR_PLLMULL13
#define RCC_PLL_MUL14 RCC_CFGR_PLLMULL14
#define RCC_PLL_MUL15 RCC_CFGR_PLLMULL15
#define RCC_PLL_MUL16 RCC_CFGR_PLLMULL16
From 2 To 16 There are these frequencies to choose
*/
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) // Perform initialization of clock frequency configuration , Maximum output of external crystal oscillator clock after frequency doubling 72M
{
while(1);
}
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
/*
RCC_CLOCKTYPE_SYSCLK Select this to configure the system clock HSE,HSI, still PLL,
RCC_CLOCKTYPE_HCLK Select this to configure AHB The clock ,
RCC_CLOCKTYPE_PCLK1 Select this to configure APB1 The clock of ,
RCC_CLOCKTYPE_PCLK2 Select this to configure APB2 The clock of .
*/
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
/*
#define RCC_SYSCLKSOURCE_HSI RCC_CFGR_SW_HSI !< Select the internal high-speed clock as the system clock
#define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_HSE !< Select the external crystal oscillator clock as the system clock
#define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_PLL !< Choose PLL clock as the system clock
*/
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; //AHB Clock division is divided by 1~512 One of the values
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; //APB1 The clock frequency division , First get from the system clock frequency division AHB The clock , Again from AHB The clock is divided according to this option APB1 The frequency of , The final calculation shall not exceed 36MHz
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; //APB2 The clock frequency division , First get from the system clock frequency division AHB The clock , Again from AHB The clock is divided according to this option APB2 The frequency of , The final calculation shall not exceed 72MHz
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) // Execute the configuration of the system clock and the clock of the system clock frequency division to the following components .
{
while(1);
}
}
边栏推荐
- 【论文阅读】2022年最新迁移学习综述笔注(Transferability in Deep Learning: A Survey)
- STM32 tutorial triple ADC interleaved sampling
- [trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
- Introduction of air gap, etc
- 研究發現,跨境電商客服系統都有這五點功能!
- Adaptive filter
- Classic application of MOS transistor circuit design (1) -iic bidirectional level shift
- Design a clock frequency division circuit that can be switched arbitrarily
- Zero length array in GNU C
- Define in and define out
猜你喜欢
![[cloud native | learn kubernetes from scratch] III. kubernetes cluster management tool kubectl](/img/8a/702019b44c8e60dffbcd898330afcb.png)
[cloud native | learn kubernetes from scratch] III. kubernetes cluster management tool kubectl
![Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine](/img/f9/fc4f0bbce36b3c1368d838d723b027.jpg)
Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine

Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic

Improve lighting C program
![Shape template matching based on Halcon learning [VII] reuse_ model. Hdev routine](/img/55/0f05291755dc1c3c03db8e991a1ba1.jpg)
Shape template matching based on Halcon learning [VII] reuse_ model. Hdev routine

Several important parameters of LDO circuit design and type selection

Connection mode - bridge and net

Mlperf training v2.0 list released, with the same GPU configuration, the performance of Baidu PaddlePaddle ranks first in the world
![C WinForm [change the position of the form after running] - Practical Exercise 4](/img/f7/ddaf5773295ca6929d39d7aa760d36.jpg)
C WinForm [change the position of the form after running] - Practical Exercise 4
![[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code](/img/58/576b6b77509ed7a9bef138f3899e37.jpg)
[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
随机推荐
Semiconductor devices (I) PN junction
Record the opening ceremony of Beijing Winter Olympics with display equipment
Problem solving: interpreter error: no file or directory
Negative pressure generation of buck-boost circuit
Record the torch encountered by win10 cuda. is_ False problem in available()
如何将EasyCVR平台RTSP接入的设备数据迁移到EasyNVR中?
[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
The firmware of the connected j-link does not support the following memory access
[trio basic tutorial 18 from introduction to proficiency] trio motion controller UDP fast exchange data communication
WiFi wpa_ Detailed description of supplicant hostpad interface
Several important parameters of LDO circuit design and type selection
Void* C is a carrier for realizing polymorphism
Wifi-802.11 negotiation rate table
Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
【论文阅读】2022年最新迁移学习综述笔注(Transferability in Deep Learning: A Survey)
Management and use of DokuWiki (supplementary)
General makefile (I) single C language compilation template
Extern keyword function
Embedded composition and route
Define in and define out