#include "stm32f10x.h"                  // Device header

int main(void)
{
// 打卡GPIOC的时钟
RCC->APB2ENR = 0x00000010;
GPIOC->CRH = 0x00300000;
// 控制PC13等是否点亮 全0 为亮 00002000是灭灯
GPIOC->ODR = 0x00000000;
while(1)
{ }
}

使用库函数点亮:封装了直接操作寄存器的代码;

#include "stm32f10x.h"                  // Device header

int main(void)
{
// 配置外设时钟
// RCC_APB2PeriphClockCmd 2 个参数 1. 设备 2. 是否
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
// 定义一个 GPIO_InitTypeDef 结构体
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
// 设置高电频开始电灯 -- 灯灭
// GPIO_SetBits(GPIOC,GPIO_Pin_13);
// 低电频 -- 灯亮
GPIO_ResetBits(GPIOC,GPIO_Pin_13);
while(1)
{ } }

ps:

#define GPIO_Pin_0                 ((uint16_t)0x0001)  /*!< Pin 0 selected */
#define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */
#define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */
#define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */
#define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */
#define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */
#define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */
#define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */
#define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */
#define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */
#define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */
#define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */
#define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */
#define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */
#define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */
#define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */
#define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */

点亮PC13- 使用寄存器点亮的更多相关文章

  1. 第7章 使用寄存器点亮LED灯

    第7章     使用寄存器点亮LED灯 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/fir ...

  2. 第7章 使用寄存器点亮LED灯—零死角玩转STM32-F429系列

    第7章     使用寄存器点亮LED灯 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/fir ...

  3. STM32F4 阿波罗寄存器点亮LED灯

    学习步骤: 使用寄存器点亮LED灯,需要进行如下的步骤,LED灯属于外设部分,首先需要开启外设的时钟使能,然后LED灯是PB1口,(芯片是正点原子的阿波罗),接着定义GPIOB口的输出模式,为上拉.推 ...

  4. 使用寄存器点亮LED——2

    1. 项目:使用stm32寄存器点亮LED, 分别点亮红.绿.蓝3个灯. 2. 步骤 先新建个文件夹保存项目 再新建项目 将startup_stm32f10x_hd.s拷贝到该文件夹下 新建main. ...

  5. 使用寄存器点亮LED

    1. 项目:使用stm32寄存器点亮LED, 分别点亮红.绿.蓝3个灯. 2. 代码: 只需要编写main.c程序,stm3210x.h程序为空(只需要新建即可). 2.1 点亮绿灯main.c程序 ...

  6. stm32F103C8T6通过写寄存器点亮LED灯

    因为我写寄存器的操作不太熟练,所以最近腾出时间学习了一下怎么写寄存器,现在把我的经验贴出来,如有不足请指正 我使用的板子是stm32F103C8T6(也就是最常用的板子),现在要通过写GPIO的寄存器 ...

  7. 使用寄存器点亮LED——编程实战

    stm32的编程和stc89c51还是存在着很多思想上的不同的,在51单片机中,我们点亮LED灯,只用给对应IO高低电平就可以了,而stm32中,就一个简单的GPIO,我们也需要配置好几个寄存器,而且 ...

  8. 使用寄存器点亮LED——前言基础知识

    在点亮LED之前,我们需要具备一些基础知识: GPIO—general purpose intput output 是通用输入输出端口的简称,简单来说就是软件可控制的引脚,STM32芯片的GPIO引脚 ...

  9. 使用寄存器点亮LED(第2节)—寄存器映射代码讲解

    // 打开 GPIOB 端口的时钟 *( unsigned int * )0x40021018|= ( 1 << 4 ); // 配置PC2 IO口为通用推挽输出,速度为10M *( un ...

  10. 使用寄存器点亮LED(第1节)—GPIO功能框图讲解

    GPIO简介 GPIO 是通用输入输出端口的简称,简单来说就是 STM32 可控制的引脚, STM32 芯片的 GPIO 引脚与外部设备连接起来,从而实现与外部通讯.控制以及数据采集的功能.STM32 ...

随机推荐

  1. 【Java】Oshi 硬件信息读取库

    实现的功能: 用于开发服务器监控面板,获取服务器硬件参数 官方Github仓库地址: https://github.com/oshi/oshi Maven坐标: <!-- https://mvn ...

  2. 【微信小程序】 列表查询功能

    对应本地生活案例: https://www.bilibili.com/video/BV1834y1676P?p=52 HTML代码部分: 就是普通的wx-for指令遍历 <!--pages/cl ...

  3. 【Zookeeper】Win平台伪集群搭建

    下载稳定版Zookeeper https://downloads.apache.org/zookeeper/stable/ GZ包: apache-zookeeper-3.6.3-bin.tar.gz ...

  4. 【TypeScript】01 基础入门

    前提:使用TypeScript你需要安装NodeJS支持 然后安装TypeScript: npm intsall -g typescript 安装完成后查看版本号: tsc -v 新建一个TypeSc ...

  5. 机器人控制与图网络( 利用关系归纳偏置改善泛化和控制)—— Robotic Control with Graph Networks——Exploiting relational inductive bias to improve generalization and control

    英文原文: https://towardsdatascience.com/robotic-control-with-graph-networks-f1b8d22b8c86 强化学习算法是不是另一种形式 ...

  6. reinforcement learning常用的游戏环境,gym框架使用的标准Atari游戏集合

    reinforcement learning常用的游戏环境,gym框架使用的标准Atari游戏集合.*.bin文件为Atari2600游戏的常用游戏环境的模拟文件,也称为roms文件. 文件地址: h ...

  7. 为baselines算法库安装mujoco环境支持——ubuntu 20.04安装MuJoCo2.1.1

    下载开源版本的mujoco二进制文件: wget https://github.com/deepmind/mujoco/releases/download/2.1.1/mujoco-2.1.1-lin ...

  8. 【转载】python的魔法方法———A Guide to Python's Magic Methods

    原文地址: https://rszalski.github.io/magicmethods/ ===================================================== ...

  9. 使用 preloadRouteComponents 提升 Nuxt 应用的性能

    title: 使用 preloadRouteComponents 提升 Nuxt 应用的性能 date: 2024/8/19 updated: 2024/8/19 author: cmdragon e ...

  10. Microsoft Build 2023 After Party (Placeholder)

    一年过去了,微软BUILD又回来了! https://build.microsoft.com/en-US/home This is a placeholder page for Microsoft B ...