STM32 MCU (1) Summary of learning materials + reference manual + LED light

Publisher:糖果龙猫Latest update time:2018-05-19 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Study Materials

Video Tutorial 

Li Xiang stm32 video tutorial 49 episodes  http://pan.baidu.com/s/1kTyt03P

Atom teaches you how to use STM32  http://pan.baidu.com/s/1gd25r6F 

Liu Yang STM32 (good)    http://pan.baidu.com/s/1mgkeNsG

 http://www.iqiyi.com/u/1005856393  http://yun.baidu.com/share/home?uk=2853967793 http://www.zxkjmcu.com/


Reference Documentation

STM32 Function Description (Chinese).pdf     http://download.csdn.net/detail/leytton/7630851

STM32 library function LED light example source code.zip  http://download.csdn.net/detail/leytton/7630863

STM32F10x Microcontroller Reference Manual (10th Edition, December 2009).pdf   http://download.csdn.net/detail/leytton/7668435 


Development board information

http://download.csdn.net/detail/leytton/7732219 

Puzhong Technology MCU Development Board STM32 Circuit Diagram (Schematic Diagram).pdf   http://download.csdn.net/detail/leytton/7732229


STM32 program download wiring diagram


Note:
1. If the program cannot be downloaded automatically, you can download the program by manually resetting it. The button operation method is: press and
hold the RSK button and press ISPK with another finger, then release the RSTK button first and then release the ISPK button. After completion, click
the "Download" button of the download software to complete the program download.
2. After the download is complete, disconnect the short-circuit cap BOTT1 so that some programs can run normally.

3. If the program does not run after downloading, you can try pressing the RSTK key on the ARM (Leytton: discovered by accident)


Tips: When programming library functions, compilation is slow. ReBuild will compile all files in the entire project. If you have only modified one file, just click Build (F7) to compile again. This will only compile the current file and the speed will be very fast.

GPIO port corresponding pins

Main function source code explanation

  1. /******************************************************************************* 

  2. *    

  3. * Software function: GPIO flashing light experiment (software delay mode) 

  4. *  

  5. *******************************************************************************/  

  6. #include "stm32f10x.h"  

  7. #include   

  8. #include "delay.h"  

  9.   

  10. /************************************************* 

  11. 函数: void RCC_Configuration(void) 

  12. Function: Reset and clock control Configuration 

  13. Parameters: None 

  14. Returns: None 

  15. **************************************************/  

  16. void RCC_Configuration(void)  

  17. {  

  18.   ErrorStatus HSEStartUpStatus; //Define the external high-speed crystal startup status enumeration variable  

  19.   RCC_DeInit(); //Reset RCC external device registers to default values  

  20.   RCC_HSEConfig(RCC_HSE_ON); //Turn on the external high-speed crystal oscillator  

  21.   HSEStartUpStatus = RCC_WaitForHSEStartUp(); //Wait for the external high-speed clock to be ready  

  22.   if(HSEStartUpStatus == SUCCESS) //The external high-speed clock is ready  

  23.   {  

  24.     FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); // Enable the FLASH pre-read buffer function to speed up the reading of FLASH. Required usage in all programs. Location: in the RCC initialization sub-function, after the clock starts  

  25.     FLASH_SetLatency(FLASH_Latency_2); //Flash operation delay  

  26.           

  27.     RCC_HCLKConfig(RCC_SYSCLK_Div1); //Configure AHB (HCLK) clock equal to == SYSCLK  

  28.     RCC_PCLK2Config(RCC_HCLK_Div1); //Configure APB2(PCLK2) clock==AHB clock  

  29.     RCC_PCLK1Config(RCC_HCLK_Div2); //Configure APB1(PCLK1) clock == AHB1/2 clock  

  30.            

  31.     RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); //Configure PLL clock == external high-speed crystal clock * 9 = 72MHz  

  32.     RCC_PLLCmd(ENABLE); //Enable PLL clock  

  33.      

  34.     while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) //Wait for PLL clock to be ready  

  35.     {  

  36.     }  

  37.     RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); //Configure system clock = PLL clock  

  38.     while(RCC_GetSYSCLKSource() != 0x08) //Check if PLL clock is used as system clock  

  39.     {  

  40.     }  

  41.   }  

  42.     

  43.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE); //Enable GPIOB and AFIO clocks  

  44. }  

  45.   

  46. /************************************************* 

  47. Function: void GPIO_Configuration(void) 

  48. Function: GPIO configuration 

  49. Parameters: None 

  50. Returns: None 

  51. **************************************************/  

  52. void GPIO_Configuration(void)  

  53. {  

  54.   GPIO_InitTypeDef GPIO_InitStructure; //Define GPIO initialization structure  

  55.   

  56.   /* Configure PE.0,PE.1,PE.2,PE.3,PE.4,PE.5,PE.6,PE.7 as Output push-pull */   

  57.   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ; //Select the GPIO pin to be set. Use the operator "|" to select multiple pins at once GPIO_Pin_0-15 GPIO_Pin_All  

  58.   GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz; //GPIO_Speed ​​is used to set the speed of the selected pin GPIO_Speed  

  59. //GPIO_Speed_10MHz maximum output rate 10MHz; PIO_Speed_2MHz maximum output rate 2MHz; GPIO_Speed_50MHz maximum output rate 50MHz  

  60.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //GPIO_Mode is used to set the working state of the selected pin  


  61. /*GPIO_Mode_AIN analog input GPIO_Mode_IN_FLOATING floating input 

  62. GPIO_Mode_IPD Pull-down input GPIO_Mode_IPU Pull-up input 

  63. GPIO_Mode_Out_OD Open-drain output GPIO_Mode_Out_PP Push-pull output 

  64. GPIO_Mode_AF_OD Multiplexed open-drain output GPIO_Mode_AF_PP Multiplexed push-pull output*/  

  65.   GPIO_Init(GPIOB, &GPIO_InitStructure);   

  66. }  

  67.   

  68.   

  69.   

  70. /************************************************* 

  71. Function: int main(void) 

  72. Function: main function 

  73. Parameters: None 

  74. Returns: None 

  75. **************************************************/  

  76. int main(void)  

  77. {  

  78.   RCC_Configuration();  

  79.   GPIO_Configuration();  

  80.   delay_init(72);  

  81.   while(1)  

  82.   {  

  83.     GPIO_SetBits(GPIOB,GPIO_Pin_0); //Set the specified data port bit  

  84.               

  85.     delay_ms(500);  

  86.     GPIO_ResetBits(GPIOB,GPIO_Pin_0); //Clear the specified data port bit  

  87.                

  88.     delay_ms(500);  

  89.     }     

  90. }  


Keywords:STM32 Reference address:STM32 MCU (1) Summary of learning materials + reference manual + LED light

Previous article:STM32 MCU (2) External interrupt
Next article:Serial port watchdog experiment

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号