#include "math.h"
int main(void)
{
//亮第一个灯
RCC->AHB1ENR |= (1<<2)|(1<<5);
GPIOC->MODER &= ~((0x3<<0)|(0x3<<12)|(0x3<<20)|(0x3<<18));
GPIOC->MODER |= (0x1<<0);
GPIOC->OTYPER &= ~(0x1<<0);
GPIOC->OSPEEDR &= ~(0x3<<0);
GPIOC->OSPEEDR |=(0x2<<0);
GPIOC->PUPDR |= ~(0x3<<0);
//亮第二三四个灯
//RCC->AHB1ENR |= (1<<5);
GPIOF->MODER &= ~((0x3<<20)|(0x3<<18)|(0x3<<12));
GPIOF->MODER |= ((0x1<<20)|(0x1<<18)|(0x1<<12));
GPIOF->OTYPER &= ~((0x1<<20)|(0x1<<18)|(0x1<<12));
GPIOF->OSPEEDR &= ~((0x3<<20)|(0x3<<18)|(0x3<<12));
GPIOF->OSPEEDR |=((0x2<<20)|(0x2<<18)|(0x2<<12));
GPIOF->PUPDR |= ~((0x3<<20)|(0x3<<18)|(0x3<<12));
//亮第三个灯
//RCC->AHB1ENR |= (1<<5);
//GPIOF->MODER &= ~(0x3<<18);
//GPIOF->MODER |= (0x1<<18);
//GPIOF->OTYPER &= ~(0x1<<18);
//GPIOF->OSPEEDR &= ~(0x3<<18);
//GPIOF->OSPEEDR |=(0x2<<18);
//GPIOF->PUPDR |= ~(0x3<<18);
//电亮第四个灯
//RCC->AHB1ENR |= (1<<5);
//GPIOF->MODER &= ~(0x3<<12);//给使用的两位清0
//GPIOF->MODER |= (0x1<<12);
//GPIOF->OTYPER &= ~(0x1<<12);
//GPIOF->OSPEEDR &= ~(0x3<<12);
//GPIOF->OSPEEDR |=(0x2<<12);
//GPIOF->PUPDR |= ~(0x3<<12);
//GPIOC->ODR |= (0x1<<0);
while (1)
{
}
}
stm32实现4个LED灯的点亮
原创
©著作权归作者所有:来自51CTO博客作者玫瑰花店的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
STM32的OLED
OLED显示,便于后期调试代码
IIC OLED -
STM32 | STM32使用固件库点亮LED
STM32 | STM32使用固件库点亮LED
stm32 单片机 嵌入式硬件 User #define -
Stm32点亮一堆灯
【代码】Stm32点亮一堆灯。
stm32 单片机 嵌入式硬件 #define 数组 -
STM32 学习7 库函数点亮LED
LED.h#ifndef _led_H#define _led_H#include "stm32f10x.h"/* LED时钟端口、引脚定义 */#define
stm32 引脚 #define #include -
STM32点亮第一盏灯
STM32点亮第一盏灯1.在原理图里面找到灯的位置2.编程实现3.编译、连接、下载运行即可1.在原理图里面
STM32第一个程序 STM32亮灯 寄存器 原理图 编程实现 -
N32WB452点亮LED灯
N32WB452点亮LED灯
初始化 延时函数 示例代码 -
STM32点亮LED
原理图 测试灯,接GPIO外设B,Pin 1...
初始化 git 原理图 数据 模版