#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. SourceGenerator 生成db to class代码优化结果记录

    优化 上一次实验 代码写的较为随意,本次穷尽所学,优化了一把, 不过果然还是没 比过 Dapper aot, 虽然没使用 Interceptor, 但理论上其优化不该有这么大差距 知识差距不少呀,都看 ...

  2. 【MySQL】java.sql.SQLException: Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '='

    问题原因参考: http://t.zoukankan.com/zhulei2-p-13451554.html collations 排序规则 Illegal mix 非法混合 SQL报错指出,操作符等 ...

  3. ViT:拉开Trasnformer在图像领域正式挑战CNN的序幕 | ICLR 2021 —— An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale

    论文地址: https://arxiv.org/abs/2010.11929 Github地址: https://github.com/google-research/vision_transform ...

  4. Implementation of Reinforcement Learning with Meta-Critic Networks and GAE in a Human-Centered Framework

    论文<Future of AI and Empowering Reinforcement Learning with Meta-Critic Networks and GAE in a Huma ...

  5. 【转载】 Parallel Computing in Python using mpi4py

    原地址: https://research.computing.yale.edu/sites/default/files/files/mpi4py.pdf ====================== ...

  6. flex布局被内容被撑开及flex布局下定宽元素被压缩

    实现效果使用flex进行左右布局,左边定宽200px,右边自适应,当右边内容过多,造成右边盒子被撑开,会造成两种问题 左边定宽盒子被压缩解决办法: flex-grow:0;//是否自动增长空间 fle ...

  7. 屏蔽RaiDrive的广告

    RaiDrive 广告域名:ads.raidrive.com 在 HOSTS 添加 127.0.0.1 ads.raidrive.com 或者在代理中设置为阻止即可. 效果: 补 最新版(2023.9 ...

  8. 直接在jsp页面上使用flex标签

    1:去ADOBE下载FLEX的TAGLIB for JSP. http://download.macromedia.com/pub/labs/flex2_tag_library_jsp/flex2_t ...

  9. 【粉丝问答8】如何用C语言在Linux下实现cc2530简单的上位机-v0.1

    0.前言 网友提问如下: 汇总下这个网友的问题,其实就是实现一个网关程序,内容分为几块: 下位机,通过串口与上位机相连: 下位机要能够接收上位机下发的命令,并解析这些命令: 下位机能够根据这些命令配置 ...

  10. 从海量信息中脱颖而出:Workflow智能分析解决方案,大语言模型为AI科技文章打造精准摘要评分体系(总篇章)

    从海量信息中脱颖而出:Workflow智能分析解决方案,大语言模型为AI科技文章打造精准摘要评分体系(总篇章) 1.简介 该项目整合了编程.AI.产品设计.商业科技及个人成长等多领域的精华内容,源自顶 ...