STM32通过PC5,PD8,PD9,PC13端口实现正向延时500ms(从左向右点亮LED)
时间: 2023-03-29 10:04:40 浏览: 82
可以使用以下代码实现:
#include "stm32f10x.h"
void delay(uint32_t time)
{
while(time--);
}
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);
delay(720000);
GPIO_SetBits(GPIOD, GPIO_Pin_8);
delay(720000);
GPIO_ResetBits(GPIOC, GPIO_Pin_5);
delay(720000);
GPIO_ResetBits(GPIOD, GPIO_Pin_8);
delay(720000);
GPIO_SetBits(GPIOC, GPIO_Pin_13);
delay(720000);
GPIO_SetBits(GPIOD, GPIO_Pin_9);
delay(720000);
GPIO_ResetBits(GPIOC, GPIO_Pin_13);
delay(720000);
GPIO_ResetBits(GPIOD, GPIO_Pin_9);
delay(720000);
}
return ;
}
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.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)