当前位置: 首页 > news >正文

河北网站建设收益/软文广告示范

河北网站建设收益,软文广告示范,成都网站建设是什么,互联网 网站建设概述 STM32F10x.h 是 STM32F1 系列微控制器的核心头文件,提供了所有外设寄存器的定义和内存映射 一、内存映射 #define PERIPH_BASE ((uint32_t)0x40000000)#define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE 0x…

概述

  • STM32F10x.h 是 STM32F1 系列微控制器的核心头文件,提供了所有外设寄存器的定义和内存映射

一、内存映射

#define PERIPH_BASE           ((uint32_t)0x40000000)
#define APB1PERIPH_BASE       PERIPH_BASE
#define APB2PERIPH_BASE       (PERIPH_BASE + 0x10000)
#define AHBPERIPH_BASE        (PERIPH_BASE + 0x20000)
  1. PERIPH_BASE 是片上外设的起始地址,对于STM32系列是 0x40000000

  2. 根据这个基础地址,APB1、APB2、AHB 外设的地址空间是依次偏移的,分别为 +0x000000x100000x20000

#define GPIOA_BASE            (APB2PERIPH_BASE + 0x0800)
#define GPIOB_BASE            (APB2PERIPH_BASE + 0x0C00)
#define GPIOC_BASE            (APB2PERIPH_BASE + 0x1000)
#define GPIOD_BASE            (APB2PERIPH_BASE + 0x1400)
#define GPIOE_BASE            (APB2PERIPH_BASE + 0x1800)
#define GPIOF_BASE            (APB2PERIPH_BASE + 0x1C00)
#define GPIOG_BASE            (APB2PERIPH_BASE + 0x2000)
  1. 访问 GPIO 外设的基地址定义,它们基于 APB2PERIPH_BASE

  2. GPIO 的地址按端口(GPIOA、GPIOB…)依次偏移 0x400


二、寄存器结构体与宏

1、复位和时钟控制 RCC
typedef struct
{__IO uint32_t CR;			// 时钟控制寄存器__IO uint32_t CFGR;		// 时钟配置寄存器__IO uint32_t CIR;		// 时钟中断寄存器__IO uint32_t APB2RSTR;	// APB2 外设复位寄存器__IO uint32_t APB1RSTR;	// APB1 外设复位寄存器__IO uint32_t AHBENR;		// AHB 外设时钟使能寄存器__IO uint32_t APB2ENR;	// APB2 外设时钟使能寄存器__IO uint32_t APB1ENR;	// APB1 外设时钟使能寄存器__IO uint32_t BDCR;		// 备份域控制寄存器__IO uint32_t CSR;		// 控制 / 状态寄存器#ifdef STM32F10X_CL  __IO uint32_t AHBRSTR;__IO uint32_t CFGR2;
#endif#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)   uint32_t RESERVED0;__IO uint32_t CFGR2;
#endif
} RCC_TypeDef;
#define RCC                 ((RCC_TypeDef *) RCC_BASE)
2、通用输入输出 GPIO
typedef struct
{__IO uint32_t CRL;     // 端口配置低寄存器__IO uint32_t CRH;     // 端口配置高寄存器__IO uint32_t IDR;     // 输入数据寄存器__IO uint32_t ODR;     // 输出数据寄存器__IO uint32_t BSRR;    // 位设置/清除寄存器__IO uint32_t BRR;     // 位清除寄存器__IO uint32_t LCKR;    // 配置锁定寄存器
} GPIO_TypeDef;
#define GPIOA               ((GPIO_TypeDef *) GPIOA_BASE)
#define GPIOB               ((GPIO_TypeDef *) GPIOB_BASE)
#define GPIOC               ((GPIO_TypeDef *) GPIOC_BASE)
#define GPIOD               ((GPIO_TypeDef *) GPIOD_BASE)
#define GPIOE               ((GPIO_TypeDef *) GPIOE_BASE)
#define GPIOF               ((GPIO_TypeDef *) GPIOF_BASE)
#define GPIOG               ((GPIO_TypeDef *) GPIOG_BASE)

三、寄存器位定义

1、RCC_APB2RSTR 寄存器位定义
#define  RCC_APB2ENR_AFIOEN                  ((uint32_t)0x00000001)         /*!< Alternate Function I/O clock enable */
#define  RCC_APB2ENR_IOPAEN                  ((uint32_t)0x00000004)         /*!< I/O port A clock enable */
#define  RCC_APB2ENR_IOPBEN                  ((uint32_t)0x00000008)         /*!< I/O port B clock enable */
#define  RCC_APB2ENR_IOPCEN                  ((uint32_t)0x00000010)         /*!< I/O port C clock enable */
#define  RCC_APB2ENR_IOPDEN                  ((uint32_t)0x00000020)         /*!< I/O port D clock enable */
#define  RCC_APB2ENR_ADC1EN                  ((uint32_t)0x00000200)         /*!< ADC 1 interface clock enable */#if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
#define  RCC_APB2ENR_ADC2EN                  ((uint32_t)0x00000400)         /*!< ADC 2 interface clock enable */
#endif#define  RCC_APB2ENR_TIM1EN                  ((uint32_t)0x00000800)         /*!< TIM1 Timer clock enable */
#define  RCC_APB2ENR_SPI1EN                  ((uint32_t)0x00001000)         /*!< SPI 1 clock enable */
#define  RCC_APB2ENR_USART1EN                ((uint32_t)0x00004000)         /*!< USART1 clock enable */#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
#define  RCC_APB2ENR_TIM15EN                 ((uint32_t)0x00010000)         /*!< TIM15 Timer clock enable */
#define  RCC_APB2ENR_TIM16EN                 ((uint32_t)0x00020000)         /*!< TIM16 Timer clock enable */
#define  RCC_APB2ENR_TIM17EN                 ((uint32_t)0x00040000)         /*!< TIM17 Timer clock enable */
#endif#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)#define  RCC_APB2ENR_IOPEEN                 ((uint32_t)0x00000040)         /*!< I/O port E clock enable */
#endif /* STM32F10X_LD && STM32F10X_LD_VL */#if defined (STM32F10X_HD) || defined (STM32F10X_XL)#define  RCC_APB2ENR_IOPFEN                 ((uint32_t)0x00000080)         /*!< I/O port F clock enable */#define  RCC_APB2ENR_IOPGEN                 ((uint32_t)0x00000100)         /*!< I/O port G clock enable */#define  RCC_APB2ENR_TIM8EN                 ((uint32_t)0x00002000)         /*!< TIM8 Timer clock enable */#define  RCC_APB2ENR_ADC3EN                 ((uint32_t)0x00008000)         /*!< DMA1 clock enable */
#endif#if defined (STM32F10X_HD_VL)#define  RCC_APB2ENR_IOPFEN                 ((uint32_t)0x00000080)         /*!< I/O port F clock enable */#define  RCC_APB2ENR_IOPGEN                 ((uint32_t)0x00000100)         /*!< I/O port G clock enable */
#endif#ifdef STM32F10X_XL#define  RCC_APB2ENR_TIM9EN                 ((uint32_t)0x00080000)         /*!< TIM9 Timer clock enable  */#define  RCC_APB2ENR_TIM10EN                ((uint32_t)0x00100000)         /*!< TIM10 Timer clock enable  */#define  RCC_APB2ENR_TIM11EN                ((uint32_t)0x00200000)         /*!< TIM11 Timer clock enable */
#endif
宏定义说明
RCC_APB2ENR_AFIOE0x00000001复位 AFIO
RCC_APB2ENR_IOPAEN0x00000004使能 GPIOA
RCC_APB2ENR_IOPBEN0x00000008使能 GPIOB
RCC_APB2ENR_IOPCEN0x00000010使能 GPIOC
RCC_APB2ENR_IOPDEN0x00000020使能 GPIOD
RCC_APB2ENR_ADC1EN0x00000200使能 ADC1
RCC_APB2ENR_TIM1EN0x00000800使能高级定时器 TIM1
RCC_APB2ENR_SPI1EN0x00001000使能 SPI1
RCC_APB2ENR_USART1EN0x00004000使能 USART1
2、GPIO_CRL 寄存器位定义
#define  GPIO_CRL_MODE                       ((uint32_t)0x33333333)        /*!< Port x mode bits */#define  GPIO_CRL_MODE0                      ((uint32_t)0x00000003)        /*!< MODE0[1:0] bits (Port x mode bits, pin 0) */
#define  GPIO_CRL_MODE0_0                    ((uint32_t)0x00000001)        /*!< Bit 0 */
#define  GPIO_CRL_MODE0_1                    ((uint32_t)0x00000002)        /*!< Bit 1 */#define  GPIO_CRL_MODE1                      ((uint32_t)0x00000030)        /*!< MODE1[1:0] bits (Port x mode bits, pin 1) */
#define  GPIO_CRL_MODE1_0                    ((uint32_t)0x00000010)        /*!< Bit 0 */
#define  GPIO_CRL_MODE1_1                    ((uint32_t)0x00000020)        /*!< Bit 1 */#define  GPIO_CRL_MODE2                      ((uint32_t)0x00000300)        /*!< MODE2[1:0] bits (Port x mode bits, pin 2) */
#define  GPIO_CRL_MODE2_0                    ((uint32_t)0x00000100)        /*!< Bit 0 */
#define  GPIO_CRL_MODE2_1                    ((uint32_t)0x00000200)        /*!< Bit 1 */#define  GPIO_CRL_MODE3                      ((uint32_t)0x00003000)        /*!< MODE3[1:0] bits (Port x mode bits, pin 3) */
#define  GPIO_CRL_MODE3_0                    ((uint32_t)0x00001000)        /*!< Bit 0 */
#define  GPIO_CRL_MODE3_1                    ((uint32_t)0x00002000)        /*!< Bit 1 */#define  GPIO_CRL_MODE4                      ((uint32_t)0x00030000)        /*!< MODE4[1:0] bits (Port x mode bits, pin 4) */
#define  GPIO_CRL_MODE4_0                    ((uint32_t)0x00010000)        /*!< Bit 0 */
#define  GPIO_CRL_MODE4_1                    ((uint32_t)0x00020000)        /*!< Bit 1 */#define  GPIO_CRL_MODE5                      ((uint32_t)0x00300000)        /*!< MODE5[1:0] bits (Port x mode bits, pin 5) */
#define  GPIO_CRL_MODE5_0                    ((uint32_t)0x00100000)        /*!< Bit 0 */
#define  GPIO_CRL_MODE5_1                    ((uint32_t)0x00200000)        /*!< Bit 1 */#define  GPIO_CRL_MODE6                      ((uint32_t)0x03000000)        /*!< MODE6[1:0] bits (Port x mode bits, pin 6) */
#define  GPIO_CRL_MODE6_0                    ((uint32_t)0x01000000)        /*!< Bit 0 */
#define  GPIO_CRL_MODE6_1                    ((uint32_t)0x02000000)        /*!< Bit 1 */#define  GPIO_CRL_MODE7                      ((uint32_t)0x30000000)        /*!< MODE7[1:0] bits (Port x mode bits, pin 7) */
#define  GPIO_CRL_MODE7_0                    ((uint32_t)0x10000000)        /*!< Bit 0 */
#define  GPIO_CRL_MODE7_1                    ((uint32_t)0x20000000)        /*!< Bit 1 */#define  GPIO_CRL_CNF                        ((uint32_t)0xCCCCCCCC)        /*!< Port x configuration bits */#define  GPIO_CRL_CNF0                       ((uint32_t)0x0000000C)        /*!< CNF0[1:0] bits (Port x configuration bits, pin 0) */
#define  GPIO_CRL_CNF0_0                     ((uint32_t)0x00000004)        /*!< Bit 0 */
#define  GPIO_CRL_CNF0_1                     ((uint32_t)0x00000008)        /*!< Bit 1 */#define  GPIO_CRL_CNF1                       ((uint32_t)0x000000C0)        /*!< CNF1[1:0] bits (Port x configuration bits, pin 1) */
#define  GPIO_CRL_CNF1_0                     ((uint32_t)0x00000040)        /*!< Bit 0 */
#define  GPIO_CRL_CNF1_1                     ((uint32_t)0x00000080)        /*!< Bit 1 */#define  GPIO_CRL_CNF2                       ((uint32_t)0x00000C00)        /*!< CNF2[1:0] bits (Port x configuration bits, pin 2) */
#define  GPIO_CRL_CNF2_0                     ((uint32_t)0x00000400)        /*!< Bit 0 */
#define  GPIO_CRL_CNF2_1                     ((uint32_t)0x00000800)        /*!< Bit 1 */#define  GPIO_CRL_CNF3                       ((uint32_t)0x0000C000)        /*!< CNF3[1:0] bits (Port x configuration bits, pin 3) */
#define  GPIO_CRL_CNF3_0                     ((uint32_t)0x00004000)        /*!< Bit 0 */
#define  GPIO_CRL_CNF3_1                     ((uint32_t)0x00008000)        /*!< Bit 1 */#define  GPIO_CRL_CNF4                       ((uint32_t)0x000C0000)        /*!< CNF4[1:0] bits (Port x configuration bits, pin 4) */
#define  GPIO_CRL_CNF4_0                     ((uint32_t)0x00040000)        /*!< Bit 0 */
#define  GPIO_CRL_CNF4_1                     ((uint32_t)0x00080000)        /*!< Bit 1 */#define  GPIO_CRL_CNF5                       ((uint32_t)0x00C00000)        /*!< CNF5[1:0] bits (Port x configuration bits, pin 5) */
#define  GPIO_CRL_CNF5_0                     ((uint32_t)0x00400000)        /*!< Bit 0 */
#define  GPIO_CRL_CNF5_1                     ((uint32_t)0x00800000)        /*!< Bit 1 */#define  GPIO_CRL_CNF6                       ((uint32_t)0x0C000000)        /*!< CNF6[1:0] bits (Port x configuration bits, pin 6) */
#define  GPIO_CRL_CNF6_0                     ((uint32_t)0x04000000)        /*!< Bit 0 */
#define  GPIO_CRL_CNF6_1                     ((uint32_t)0x08000000)        /*!< Bit 1 */#define  GPIO_CRL_CNF7                       ((uint32_t)0xC0000000)        /*!< CNF7[1:0] bits (Port x configuration bits, pin 7) */
#define  GPIO_CRL_CNF7_0                     ((uint32_t)0x40000000)        /*!< Bit 0 */
#define  GPIO_CRL_CNF7_1                     ((uint32_t)0x80000000)        /*!< Bit 1 */
宏定义值(十六进制)值(二进制)功能描述
GPIO_CRL_MODE0x33333333... 00110011所有引脚的 MODE 位掩码(复位值)
GPIO_CRL_MODE00x00000003... 00000011引脚 0 的 MODE 位 0、1
GPIO_CRL_MODE0_00x00000001... 00000001引脚 0 的 MODE 位 0
GPIO_CRL_MODE0_10x00000002... 00000010引脚 0 的 MODE 位 1
GPIO_CRL_MODE10x00000030... 00110000引脚 1 的 MODE 位 4 、5
GPIO_CRL_MODE1_00x00000010... 00010000引脚 1 的 MODE 位 4
GPIO_CRL_MODE1_10x00000020... 00100000引脚 1 的 MODE 为 5
宏定义值(十六进制)值(二进制)功能描述
GPIO_CRL_CNF0xCCCCCCCC... 11001100所有引脚的 CNF 位掩码(复位值)
GPIO_CRL_CNF00x0000000C... 00001100引脚 0 的 CNF 位 2、3
GPIO_CRL_CNF0_00x00000004... 00000100引脚 0 的 CNF 位 2
GPIO_CRL_CNF0_10x00000008... 00001000引脚 0 的 CNF 位 3
GPIO_CRL_CNF10x000000C0... 11000000引脚 1 的 CNF 位 6、7
GPIO_CRL_CNF1_00x00000040... 01000000引脚 1 的 CNF 位 6
GPIO_CRL_CNF1_10x00000080... 10000000引脚 1 的 CNF 位 7
3、GPIO_ODR 寄存器位定义
#define GPIO_ODR_ODR0                        ((uint16_t)0x0001)            /*!< Port output data, bit 0 */
#define GPIO_ODR_ODR1                        ((uint16_t)0x0002)            /*!< Port output data, bit 1 */
#define GPIO_ODR_ODR2                        ((uint16_t)0x0004)            /*!< Port output data, bit 2 */
#define GPIO_ODR_ODR3                        ((uint16_t)0x0008)            /*!< Port output data, bit 3 */
#define GPIO_ODR_ODR4                        ((uint16_t)0x0010)            /*!< Port output data, bit 4 */
#define GPIO_ODR_ODR5                        ((uint16_t)0x0020)            /*!< Port output data, bit 5 */
#define GPIO_ODR_ODR6                        ((uint16_t)0x0040)            /*!< Port output data, bit 6 */
#define GPIO_ODR_ODR7                        ((uint16_t)0x0080)            /*!< Port output data, bit 7 */
#define GPIO_ODR_ODR8                        ((uint16_t)0x0100)            /*!< Port output data, bit 8 */
#define GPIO_ODR_ODR9                        ((uint16_t)0x0200)            /*!< Port output data, bit 9 */
#define GPIO_ODR_ODR10                       ((uint16_t)0x0400)            /*!< Port output data, bit 10 */
#define GPIO_ODR_ODR11                       ((uint16_t)0x0800)            /*!< Port output data, bit 11 */
#define GPIO_ODR_ODR12                       ((uint16_t)0x1000)            /*!< Port output data, bit 12 */
#define GPIO_ODR_ODR13                       ((uint16_t)0x2000)            /*!< Port output data, bit 13 */
#define GPIO_ODR_ODR14                       ((uint16_t)0x4000)            /*!< Port output data, bit 14 */
#define GPIO_ODR_ODR15                       ((uint16_t)0x8000)            /*!< Port output data, bit 15 */
宏定义值(十六进制)二进制值说明
GPIO_ODR_ODR00x0001... 00000001设置引脚 0
GPIO_ODR_ODR10x0002... 00000010设置引脚 1
GPIO_ODR_ODR20x0004... 00000100设置引脚 2
GPIO_ODR_ODR30x0008... 00001000设置引脚 3

实现点灯案例

#include "stm32f10x.h"int main()
{// RCC APB2 使能RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;// 清除 PB5 的配置位 [23:20]// GPIO_CRL_MODE5 为 00000000 00110000 00000000 00000000// GPIO_CRL_CNF5 为 00000000 11000000 00000000 00000000// GPIO_CRL_MODE5 | GPIO_CRL_CNF5 得到 00000000 11110000 00000000 00000000// ~(GPIO_CRL_MODE5 | GPIO_CRL_CNF5) 得到 11111111 00001111 11111111 11111111GPIOB->CRL &= ~(GPIO_CRL_MODE5 | GPIO_CRL_CNF5);// 设置 PB5 为推挽输出模式,最大速度为 50MH// GPIO_CRL_MODE5_0 为 00000000 00010000 00000000 00000000// GPIO_CRL_MODE5_1 为 00000000 00100000 00000000 00000000// GPIO_CRL_MODE5_0 | GPIO_CRL_MODE5_1 得到 00000000 00110000 00000000 00000000GPIOB->CRL |= GPIO_CRL_MODE5_0 | GPIO_CRL_MODE5_1;// 点亮 PB5// GPIO_ODR_ODR5 为 00000000 00000000 00000000 00010000// ~GPIO_ODR_ODR5 得到 11111111 11111111 11111111 11101111GPIOB->ODR &= ~GPIO_ODR_ODR5;while (1){}
}
http://www.whsansanxincailiao.cn/news/30241974.html

相关文章:

  • 100款禁用网站/2023年第三波疫情9月
  • seo搜索引擎优化师/青岛seo招聘
  • 网站怎么屏蔽ip访问/百度快照优化排名推广怎么做
  • 网站建设网络推广最低价格/优化网站内容的方法
  • 蓝色科技企业网站模板免费下载/今日国际新闻摘抄
  • wordpress网站怎样/百度网址大全下载安装
  • 做简单网站需要学什么软件/微信营销是什么
  • 网站开发流程分析/适合交换友情链接的是
  • 企业建网站计什么科目/如何做营销
  • 浦江县建设局网站/12月10日新闻
  • 网页制作设计公司排名/福州seo公司排名
  • 做展示网站要恋用什么程序/厦门百度推广排名优化
  • php网站留言板模板下载/郑州有没有厉害的seo
  • 网站报错404/成都网站推广
  • 做网站的教学视频/国内免费发布产品的平台
  • 一千元做网站/企业网站seo服务
  • 齐诺网站建设东莞网站建设做网站/流量网站
  • 国贸附近网站建设/视频网站推广
  • pc网站开发成app难度/html网页制作模板
  • 网站所有分类中 点击箭头不出现下拉菜单/中国进入一级战备状态了吗
  • 做网站是html好还是java好/进入百度搜索网站
  • 网站制作常见问题/郑州网站优化顾问
  • 揭阳城乡建设局网站/seo手机关键词网址
  • 网络网站制作技巧/百度搜索引擎网址格式
  • 中宁网站建设/seo搜索优化培训
  • 建设厅网站关于建筑资质合并/合肥seo报价
  • 自做网站多少钱/seo是什么职务
  • 焦作建设厅网站/如何查询百度收录
  • 深圳做网站的大公司/好的营销网站设计公司
  • ppt中仿网站链接怎么做/谷歌seo外链平台