{"id":291,"date":"2024-06-25T15:34:58","date_gmt":"2024-06-25T07:34:58","guid":{"rendered":"https:\/\/aoofoo.com\/?p=291"},"modified":"2024-09-09T16:26:56","modified_gmt":"2024-09-09T08:26:56","slug":"2-5-led%e9%97%aa%e7%83%81%e3%80%81%e6%b5%81%e6%b0%b4%e7%81%af%e3%80%81%e8%9c%82%e9%b8%a3%e5%99%a8","status":"publish","type":"post","link":"https:\/\/aoofoo.com\/index.php\/2024\/06\/25\/2-5-led%e9%97%aa%e7%83%81%e3%80%81%e6%b5%81%e6%b0%b4%e7%81%af%e3%80%81%e8%9c%82%e9%b8%a3%e5%99%a8\/","title":{"rendered":"2.5 LED\u95ea\u70c1\u3001\u6d41\u6c34\u706f\u3001\u8702\u9e23\u5668"},"content":{"rendered":"<h2>\u5bfc\u8bed<\/h2>\n<p>\u6211\u4eec\u9700\u8981\u5148\u642d\u5efa\u4e00\u4e0b\u9762\u5305\u677f\u7535\u8def\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-292\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-37.png\" alt=\"\" width=\"2268\" height=\"752\" \/><\/p>\n<h2>RCC\/GPIO\u5e93\u51fd\u6570<\/h2>\n<p>\u6211\u4eec\u4e4b\u524d\u8bf4\u8fc7\uff0c\u64cd\u4f5cSTM32\u7684GPIO\u603b\u5171\u9700\u89813\u4e2a\u6b65\u9aa4\uff0c\u7b2c\u4e00\u6b65\uff0c\u4f7f\u7528RCC\u5f00\u542fGPIO\u7684\u65f6\u949f\uff1b\u7b2c\u4e8c\u6b65\uff0c\u4f7f\u7528GPIO_Init\u51fd\u6570\u521d\u59cb\u5316GPIO\uff1b\u7b2c\u4e09\u6b65\uff0c\u4f7f\u7528\u8f93\u51fa\u6216\u8005\u8f93\u5165\u7684\u51fd\u6570\u63a7\u5236GPIO\u53e3\u3002\u5728\u8fd9\u91cc\u603b\u5171\u6d89\u53ca\u4e86RCC\u548cGPIO\u4e24\u4e2a\u5916\u8bbe\u3002<\/p>\n<h3>RCC\u5916\u8bbe\u7528\u5230\u7684\u6700\u591a\u7684\u5e93\u51fd\u6570<\/h3>\n<div class=\"sc-star-plane sc-star-plane--1\"><div class=\"sc-star-plane__content\">\u90fd\u662f\u7b2c\u4e00\u4e2a\u53c2\u6570\u9009\u62e9\u5916\u8bbe\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4f7f\u80fd\u6216\u8005\u5931\u80fd<\/div><\/div>\n<p>RCC AHB\u5916\u8bbe\u65f6\u949f\u63a7\u5236:void RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState);<\/p>\n<div class=\"sc-collapse\"><div class=\"sc-collapse__header\"><svg class=\"sc-collapse__arrow\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 9 12 15 18 9\"\/><\/svg>\u4ee3\u7801\u8be6\u60c5\u9875<\/div><div class=\"sc-collapse__body\"><div class=\"sc-collapse__content\">\n<pre class=\"corepress-code-pre\"><code>\/**\r\n  * @brief  Enables or disables the AHB peripheral clock.\r\n  * @param  RCC_AHBPeriph: specifies the AHB peripheral to gates its clock.\r\n  *   \r\n  *   For @b STM32_Connectivity_line_devices, this parameter can be any combination\r\n  *   of the following values:        \r\n  *     @arg RCC_AHBPeriph_DMA1\r\n  *     @arg RCC_AHBPeriph_DMA2\r\n  *     @arg RCC_AHBPeriph_SRAM\r\n  *     @arg RCC_AHBPeriph_FLITF\r\n  *     @arg RCC_AHBPeriph_CRC\r\n  *     @arg RCC_AHBPeriph_OTG_FS    \r\n  *     @arg RCC_AHBPeriph_ETH_MAC   \r\n  *     @arg RCC_AHBPeriph_ETH_MAC_Tx\r\n  *     @arg RCC_AHBPeriph_ETH_MAC_Rx\r\n  * \r\n  *   For @b other_STM32_devices, this parameter can be any combination of the \r\n  *   following values:        \r\n  *     @arg RCC_AHBPeriph_DMA1\r\n  *     @arg RCC_AHBPeriph_DMA2\r\n  *     @arg RCC_AHBPeriph_SRAM\r\n  *     @arg RCC_AHBPeriph_FLITF\r\n  *     @arg RCC_AHBPeriph_CRC\r\n  *     @arg RCC_AHBPeriph_FSMC\r\n  *     @arg RCC_AHBPeriph_SDIO\r\n  *   \r\n  * @note SRAM and FLITF clock can be disabled only during sleep mode.\r\n  * @param  NewState: new state of the specified peripheral clock.\r\n  *   This parameter can be: ENABLE or DISABLE.\r\n  * @retval None\r\n  *\/\r\nvoid RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState)\r\n{\r\n  \/* Check the parameters *\/\r\n  assert_param(IS_RCC_AHB_PERIPH(RCC_AHBPeriph));\r\n  assert_param(IS_FUNCTIONAL_STATE(NewState));\r\n\r\n  if (NewState != DISABLE)\r\n  {\r\n    RCC-&gt;AHBENR |= RCC_AHBPeriph;\r\n  }\r\n  else\r\n  {\r\n    RCC-&gt;AHBENR &amp;= ~RCC_AHBPeriph;\r\n  }\r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><\/div><\/div><\/div><br \/>\nRCC APB2\u5916\u8bbe\u65f6\u949f\u63a7\u5236:void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);<\/p>\n<div class=\"sc-collapse\"><div class=\"sc-collapse__header\"><svg class=\"sc-collapse__arrow\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 9 12 15 18 9\"\/><\/svg>\u4ee3\u7801\u9875\u8be6\u60c5<\/div><div class=\"sc-collapse__body\"><div class=\"sc-collapse__content\"><\/p>\n<pre class=\"corepress-code-pre\"><code>\/**\r\n  * @brief  Enables or disables the High Speed APB (APB2) peripheral clock.\r\n  * @param  RCC_APB2Periph: specifies the APB2 peripheral to gates its clock.\r\n  *   This parameter can be any combination of the following values:\r\n  *     @arg RCC_APB2Periph_AFIO, RCC_APB2Periph_GPIOA, RCC_APB2Periph_GPIOB,\r\n  *          RCC_APB2Periph_GPIOC, RCC_APB2Periph_GPIOD, RCC_APB2Periph_GPIOE,\r\n  *          RCC_APB2Periph_GPIOF, RCC_APB2Periph_GPIOG, RCC_APB2Periph_ADC1,\r\n  *          RCC_APB2Periph_ADC2, RCC_APB2Periph_TIM1, RCC_APB2Periph_SPI1,\r\n  *          RCC_APB2Periph_TIM8, RCC_APB2Periph_USART1, RCC_APB2Periph_ADC3,\r\n  *          RCC_APB2Periph_TIM15, RCC_APB2Periph_TIM16, RCC_APB2Periph_TIM17,\r\n  *          RCC_APB2Periph_TIM9, RCC_APB2Periph_TIM10, RCC_APB2Periph_TIM11     \r\n  * @param  NewState: new state of the specified peripheral clock.\r\n  *   This parameter can be: ENABLE or DISABLE.\r\n  * @retval None\r\n  *\/\r\nvoid RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)\r\n{\r\n  \/* Check the parameters *\/\r\n  assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));\r\n  assert_param(IS_FUNCTIONAL_STATE(NewState));\r\n  if (NewState != DISABLE)\r\n  {\r\n    RCC-&gt;APB2ENR |= RCC_APB2Periph;\r\n  }\r\n  else\r\n  {\r\n    RCC-&gt;APB2ENR &amp;= ~RCC_APB2Periph;\r\n  }\r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><\/div><\/div><\/div>\n<p>RCC APB1\u5916\u8bbe\u65f6\u949f\u63a7\u5236:void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);<\/p>\n<div class=\"sc-collapse\"><div class=\"sc-collapse__header\"><svg class=\"sc-collapse__arrow\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 9 12 15 18 9\"\/><\/svg>\u4ee3\u7801\u9875\u8be6\u60c5<\/div><div class=\"sc-collapse__body\"><div class=\"sc-collapse__content\"><\/p>\n<pre class=\"corepress-code-pre\"><code>\/**\r\n  * @brief  Enables or disables the Low Speed APB (APB1) peripheral clock.\r\n  * @param  RCC_APB1Periph: specifies the APB1 peripheral to gates its clock.\r\n  *   This parameter can be any combination of the following values:\r\n  *     @arg RCC_APB1Periph_TIM2, RCC_APB1Periph_TIM3, RCC_APB1Periph_TIM4,\r\n  *          RCC_APB1Periph_TIM5, RCC_APB1Periph_TIM6, RCC_APB1Periph_TIM7,\r\n  *          RCC_APB1Periph_WWDG, RCC_APB1Periph_SPI2, RCC_APB1Periph_SPI3,\r\n  *          RCC_APB1Periph_USART2, RCC_APB1Periph_USART3, RCC_APB1Periph_USART4, \r\n  *          RCC_APB1Periph_USART5, RCC_APB1Periph_I2C1, RCC_APB1Periph_I2C2,\r\n  *          RCC_APB1Periph_USB, RCC_APB1Periph_CAN1, RCC_APB1Periph_BKP,\r\n  *          RCC_APB1Periph_PWR, RCC_APB1Periph_DAC, RCC_APB1Periph_CEC,\r\n  *          RCC_APB1Periph_TIM12, RCC_APB1Periph_TIM13, RCC_APB1Periph_TIM14\r\n  * @param  NewState: new state of the specified peripheral clock.\r\n  *   This parameter can be: ENABLE or DISABLE.\r\n  * @retval None\r\n  *\/\r\nvoid RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)\r\n{\r\n  \/* Check the parameters *\/\r\n  assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));\r\n  assert_param(IS_FUNCTIONAL_STATE(NewState));\r\n  if (NewState != DISABLE)\r\n  {\r\n    RCC-&gt;APB1ENR |= RCC_APB1Periph;\r\n  }\r\n  else\r\n  {\r\n    RCC-&gt;APB1ENR &amp;= ~RCC_APB1Periph;\r\n  }\r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><\/div><\/div><\/div>\n<h3>GPIO\u5916\u8bbe\u7528\u5230\u7684\u6700\u591a\u7684\u5e93\u51fd\u6570<\/h3>\n<div class=\"sc-alert sc-alert--info\"><span class=\"sc-alert__icon\"><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"\/><line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\"\/><line x1=\"12\" y1=\"8\" x2=\"12.01\" y2=\"8\"\/><\/svg><\/span><div class=\"sc-alert__content\">\u91cd\u8981\u7684\u53ea\u6709GPIO_Init\u51fd\u6570\u548c8\u4e2a\u8bfb\u5199\u51fd\u6570<\/div><\/div>\n<p>void GPIO_DeInit(GPIO_TypeDef* GPIOx);<\/p>\n<p>\u53c2\u6570\u53ef\u4ee5\u5199GPIOA,GPIOB\u7b49\u7b49\uff0c\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\u4e4b\u540e\uff0c\u6240\u6307\u5b9a\u7684GPIO\u5916\u8bbe\u5c31\u4f1a\u88ab\u590d\u4f4d\uff0c\u8fd9\u5c31\u662f\u8fd9\u4e2a\u51fd\u6570\u7684\u7528\u9014\u3002<\/p>\n<p>void GPIO_AFIODeInit(void);<\/p>\n<p>\u53ef\u4ee5\u590d\u4f4dAFIO\u5916\u8bbe\u3002<\/p>\n<p><strong>void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);<\/strong><\/p>\n<p>\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u662f\uff0c\u7528\u7ed3\u6784\u4f53\u53c2\u6570\u6765\u521d\u59cb\u5316GPIO\u53e3\uff0c\u6211\u4eec\u9700\u8981\u5148\u5b9a\u4e49\u4e00\u4e2a\u7ed3\u6784\u4f53\u53d8\u91cf\uff0c\u7136\u540e\u518d\u7ed9\u7ed3\u6784\u4f53\u8d4b\u503c\uff0c\u6700\u540e\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u8fd9\u4e2a\u51fd\u6570\u5185\u90e8\u5c31\u4f1a\u81ea\u52a8\u8bfb\u53d6\u7ed3\u6784\u4f53\u7684\u503c\uff0c\u7136\u540e\u81ea\u52a8\u628a\u5916\u8bbe\u7684\u5404\u4e2a\u53c2\u6570\u914d\u7f6e\u597d\uff0c\u8fd9\u79cdInit\u51fd\u6570\u5728STM32\u4e2d\u57fa\u672c\u6240\u6709\u7684\u5916\u8bbe\u90fd\u6709\uff0c\u4e00\u822c\u6211\u4eec\u521d\u59cb\u5316\u5916\u8bbe\u90fd\u662f\u4f7f\u7528\u8fd9\u4e2aInit\u51fd\u6570\u6765\u5b8c\u6210\u7684\u3002<br \/>\nvoid GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);<\/p>\n<p>\u8fd9\u4e2a\u51fd\u6570\u53ef\u4ee5\u628a\u7ed3\u6784\u4f53\u53d8\u91cf\u8d4b\u4ee5\u4e00\u4e2a\u9ed8\u8ba4\u503c\u3002<\/p>\n<p><strong>GPIO\u56db\u4e2a\u8bfb\u53d6\u51fd\u6570\uff1a<\/strong><br \/>\n<strong>uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);<\/strong><br \/>\n<strong>uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);<\/strong><br \/>\n<strong>uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);<\/strong><br \/>\n<strong>uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);<\/strong><\/p>\n<p><strong>GPIO\u56db\u4e2a\u8f93\u51fa\u51fd\u6570\uff1a<\/strong><br \/>\n<strong>\u628a\u6307\u5b9a\u7684\u51fd\u6570\u7684\u7aef\u53e3\u8bbe\u7f6e\u4e3a\u9ad8\u7535\u5e73\uff1a<\/strong><\/p>\n<p><strong>void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);<\/strong><\/p>\n<p><strong>\u628a\u6307\u5b9a\u7684\u7aef\u53e3\u8bbe\u7f6e\u4e3a\u4f4e\u7535\u5e73\uff1a<\/strong><\/p>\n<p><strong>void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);<\/strong><\/p>\n<p><strong>\u6839\u636e\u7b2c\u4e09\u4e2a\u53c2\u6570\u7684\u503c\u6765\u8bbe\u7f6e\u6307\u5b9a\u7684\u7aef\u53e3\uff1a<\/strong><br \/>\n<strong>void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);<\/strong><\/p>\n<p><strong>\u8fd9\u4e2a\u51fd\u6570\u53ef\u4ee5\u540c\u65f6\u5bf916\u4e2a\u7aef\u53e3\u8fdb\u884c\u5199\u5165\u64cd\u4f5c\uff1a<\/strong><br \/>\n<strong>void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);<\/strong><\/p>\n<h2>\u5199\u4ee3\u7801<\/h2>\n<p>GPIO_InitTypeDef GPIOInitStructure;<\/p>\n<p>GPIO\u76848\u79cd\u6a21\u5f0f\uff1a<\/p>\n<p>GPIO_Mode_AIN\u00a0 \u6a21\u62df\u8f93\u5165<br \/>\nGPIO_Mode_IN_FLOATING\u00a0 \u6d6e\u7a7a\u8f93\u5165<br \/>\nGPIO_Mode_IPD\u00a0 \u4e0b\u62c9\u8f93\u5165<br \/>\nGPIO_Mode_IPU\u00a0 \u4e0a\u62c9\u8f93\u5165<br \/>\nGPIO_Mode_Out_OD\u00a0 \u5f00\u6f0f\u8f93\u51fa<br \/>\nGPIO_Mode_Out_PP\u00a0 \u00a0\u63a8\u633d\u8f93\u51fa<br \/>\nGPIO_Mode_AF_OD\u00a0 \u00a0\u590d\u7528\u5f00\u6f0f<br \/>\nGPIO_Mode_AF_PP\u00a0 \u00a0 \u590d\u7528\u63a8\u633d<\/p>\n<p>\u6211\u4eec\u70b9\u706f\u7528\u7684\u662f\u63a8\u633d\u8f93\u51fa\uff0c\u6240\u4ee5\u7528\u7684\u662fGPIO_Mode_Out_PP\u3002<\/p>\n<p>\u70b9\u4eaeLED\u4ee3\u7801\uff1a<\/p>\n<pre class=\"corepress-code-pre\"><code>#include \"stm32f10x.h\"\r\n\r\nint main(void){\r\n\tRCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);\r\n\tGPIO_InitTypeDef GPIO_InitStructure;\r\n\tGPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;\r\n\tGPIO_InitStructure.GPIO_Pin =GPIO_Pin_0;\r\n\tGPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;\r\n\tGPIO_Init(GPIOA,&amp;GPIO_InitStructure); \/\/GPIOA\u5916\u8bbe\u76840\u53f7\u5f15\u811a\u5c31\u81ea\u52a8\u88ab\u914d\u7f6e\u4e3a\u63a8\u633d\u8f93\u51fa\u300150MHz\u7684\u901f\u5ea6\u4e86\u3002\r\n\t\r\n\tGPIO_ResetBits(GPIOA,GPIO_Pin_0);\r\n\t\r\n\twhile(1){\r\n\t\r\n\t}\r\n}<\/code><\/pre>\n<p>\u95ea\u70c1LED\u4ee3\u7801\uff1a<\/p>\n<pre class=\"corepress-code-pre\"><code>#include \"stm32f10x.h\"\r\n#include \"Delay.h\"\r\nint main(void){\r\n\tRCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);\r\n\tGPIO_InitTypeDef GPIO_InitStructure;\r\n\tGPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;\r\n\tGPIO_InitStructure.GPIO_Pin =GPIO_Pin_0;\r\n\tGPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;\r\n\tGPIO_Init(GPIOA,&amp;GPIO_InitStructure); \/\/GPIOA\u5916\u8bbe\u76840\u53f7\u5f15\u811a\u5c31\u81ea\u52a8\u88ab\u914d\u7f6e\u4e3a\u63a8\u633d\u8f93\u51fa\u300150MHz\u7684\u901f\u5ea6\u4e86\u3002\r\n\t\r\n\tGPIO_ResetBits(GPIOA,GPIO_Pin_0);\r\n\t\r\n\twhile(1){\r\n\t\tGPIO_ResetBits(GPIOA,GPIO_Pin_0);\r\n\t\tDelay_ms(500);\r\n\t\tGPIO_SetBits(GPIOA,GPIO_Pin_0);\r\n\t\tDelay_ms(500);\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>LED\u6d41\u6c34\u706f\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-305\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-38.png\" alt=\"\" width=\"2285\" height=\"788\" \/><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"corepress-code-pre\"><code>#include \"stm32f10x.h\"\r\n#include \"Delay.h\"\r\nint main(void){\r\n\tRCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);\r\n\tGPIO_InitTypeDef GPIO_InitStructure;\r\n\tGPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;\r\n\tGPIO_InitStructure.GPIO_Pin =GPIO_Pin_All;\r\n\tGPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;\r\n\tGPIO_Init(GPIOA,&amp;GPIO_InitStructure); \/\/GPIOA\u5916\u8bbe\u7684\u6240\u6709\u5f15\u811a\u5c31\u81ea\u52a8\u88ab\u914d\u7f6e\u4e3a\u63a8\u633d\u8f93\u51fa\u300150MHz\u7684\u901f\u5ea6\u4e86\u3002\r\n\t\r\n\twhile(1){\r\n\t\tGPIO_ResetBits(GPIOA,GPIO_Pin_0);\r\n\t\tDelay_ms(100);\r\n\t\tGPIO_SetBits(GPIOA,GPIO_Pin_0);\r\n\t\tDelay_ms(100);\r\n\t\tGPIO_ResetBits(GPIOA,GPIO_Pin_1);\r\n\t\tDelay_ms(100);\r\n\t\tGPIO_SetBits(GPIOA,GPIO_Pin_1);\r\n\t\tDelay_ms(100);\r\n\t\tGPIO_ResetBits(GPIOA,GPIO_Pin_2);\r\n\t\tDelay_ms(100);\r\n\t\tGPIO_SetBits(GPIOA,GPIO_Pin_2);\r\n\t\tDelay_ms(100);\r\n\t\tGPIO_ResetBits(GPIOA,GPIO_Pin_3);\r\n\t\tDelay_ms(100);\r\n\t\tGPIO_SetBits(GPIOA,GPIO_Pin_3);\r\n\t\tDelay_ms(100);\r\n\t\tGPIO_ResetBits(GPIOA,GPIO_Pin_4);\r\n\t\tDelay_ms(100);\r\n\t\tGPIO_SetBits(GPIOA,GPIO_Pin_4);\r\n\t\tDelay_ms(100);\r\n\t\tGPIO_ResetBits(GPIOA,GPIO_Pin_7);\r\n\t\tDelay_ms(100);\r\n\t\tGPIO_SetBits(GPIOA,GPIO_Pin_7);\r\n\t\tDelay_ms(100);\r\n\t}\r\n}<\/code><\/pre>\n<p>\u8702\u9e23\u5668\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-307\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-39.png\" alt=\"\" width=\"2202\" height=\"798\" \/><\/p>\n<pre class=\"corepress-code-pre\"><code>#include \"stm32f10x.h\"\r\n#include \"Delay.h\"\r\nint main(void){\r\n\tRCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);\r\n\tGPIO_InitTypeDef GPIO_InitStructure;\r\n\tGPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;\r\n\tGPIO_InitStructure.GPIO_Pin =GPIO_Pin_12;\r\n\tGPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;\r\n\tGPIO_Init(GPIOB,&amp;GPIO_InitStructure); \/\/GPIOB\u5916\u8bbe\u768412\u5f15\u811a\u5c31\u81ea\u52a8\u88ab\u914d\u7f6e\u4e3a\u63a8\u633d\u8f93\u51fa\u300150MHz\u7684\u901f\u5ea6\u4e86\u3002\r\n\t\r\n\twhile(1){\r\n\t\tGPIO_ResetBits(GPIOB,GPIO_Pin_12);\r\n\t\tDelay_ms(1000);\r\n\t\tGPIO_SetBits(GPIOB,GPIO_Pin_12);\r\n\t\tDelay_ms(1000);\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5bfc\u8bed \u6211\u4eec\u9700\u8981\u5148\u642d\u5efa\u4e00\u4e0b\u9762\u5305\u677f\u7535\u8def\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a RCC\/GPIO\u5e93\u51fd\u6570 \u6211\u4eec\u4e4b\u524d\u8bf4\u8fc7\uff0c\u64cd\u4f5cSTM32\u7684GPI [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-291","post","type-post","status-publish","format-standard","hentry","category-stm32"],"_links":{"self":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/comments?post=291"}],"version-history":[{"count":13,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"predecessor-version":[{"id":308,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/291\/revisions\/308"}],"wp:attachment":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}