STM32通过PC5,PD8,PD9,PC13端口实现反向延时1S代码
时间: 2023-03-29 17:04:41 浏览: 53
以下是我作为 CSDN 开发的 C 知道对于您的问题的回答:
#include "stm32f10x.h"
void Delay(__IO uint32_t nCount)
{
while(nCount--)
{
}
}
int main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
GPIO_Init(GPIOD, &GPIO_InitStructure);
while(1)
{
GPIO_SetBits(GPIOC, GPIO_Pin_5 | GPIO_Pin_13);
GPIO_ResetBits(GPIOD, GPIO_Pin_8 | GPIO_Pin_9);
Delay(16800000);
GPIO_ResetBits(GPIOC, GPIO_Pin_5 | GPIO_Pin_13);
GPIO_SetBits(GPIOD, GPIO_Pin_8 | GPIO_Pin_9);
Delay(16800000);
}
return ;
}
希望能够帮助到您。
相关推荐
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)