stm32f10--- 学习日志2021-07-10

不知道标题是啥-_-|||,学到什么记录什么

寄存器占四个字节

偏移地址:0x04       

基地址:0x4001 1000叫做GPIOC的基地址 

APB2外设时钟使能寄存器 0x4002 1018  单片机认为它只是一个数值,所以需要转换成单片机能识别的地址    我们需要做的是改变地址里面的值
* (unsigned int*)
  0x4002 1018    //这样单片机就可以识别这个地址了,前面一个红色星号是为了把里面的值取出来

2、配置输出,确定输出模式

先把对应控制位清零,再根据需要设置!

* (unsigned int*)  0x40011004 &=~(0x0f<<(20));//清零

* (unsigned int*)  0x4002 1018 |=(1<<20);//根据需要设置

~ 取反

3、输出低电平

     *(unsigned int*)0x40021018 |=(1<<4);
     *(unsigned int*)0x40011004 &=~(0x0F)<<(4*5);
     *(unsigned int*)0x40011004 |=(1<<(4*5));
     *(unsigned int*)0x4001100C &=~(1<<13);//输出低电平,点亮
     *(unsigned int*)0x4001100C |=(1<<13);//输出高电平,熄灭

4.点亮led灯

int main()
 {
   *(unsigned int*)0x40021018 |=(1<<4);
	  *(unsigned int*)0x40011004 &=~(0x0F)<<(4*5);
	 *(unsigned int*)0x40011004 |=(1<<(4*5));
	 *(unsigned int*)0x4001100C &=~(1<<13);
	 
	 //*(unsigned int*)0x4001100C |=(1<<13);//熄灭
	 while(1);
 }	 
 void SystemInit(void)
 {
	 
 }

点亮LED中  --寄存器

 

 

*(unsigned int*)0x40021018 |=(1<<4);

#define  RCC_APB2ENR  ( *(unsigned int*)0x40021018)

RCC_APB2ENR  |=(1<<4);
 

 

 

#define RCC_APB2ENR  *(unsigned int*)0x40021018
#define GPIOC_CRH    *(unsigned int*)0x40011004
#define GPIOC_ODR    *(unsigned int*)0x4001100C
int main()
 {
   RCC_APB2ENR |=(1<<4);
	  GPIOC_CRH &=~(0x0F)<<(4*5);
	 GPIOC_CRH |=(1<<(4*5));
	 GPIOC_ODR &=~(1<<13);
	 
	 //*(unsigned int*)0x4001100C |=(1<<13);
	 while(1);
 }	 
 void SystemInit(void)
 {
	 
 }

头文件的概念

#include<stm32f10x.h> : <>代表keil自带的头文件,只要写上就能自动寻找相应的文件夹加载

#include"stm32f10x.h"   :  "   "代表自定义的头文件,使用的时候要指明路径

基地址命名

总线 一根粗的线

外设 一根根细的线    挂在总线上

总线名称 APB1     APB2      AHB

总线基地址   0x4000 0000    0x4001 0000    0x4001 8000

#define PERIPH_BASE     0x4000 0000 //总线基地址   PERIPH——外设   BASE——基地址  

总线表示

#define APB1PERIPH_BASE   PERIPH_BASE(+偏移量)

#define APB2PERIPH_BASE   (PERIPH_BASE+0x00010000)

#define AHBPERIPH_BASE     (PERIPH_BASE+0x00020000)  //18000    20000  好计算

接下来   

       目的:点亮led

GPIOC的基地址也出来了

高寄存器GPIOC_CRH 有四位偏移量   (GPIOC_BASE+0x04)  将其转换为单片机所认识的地址  *(unsigned int*)(GPIOC_BASE+0x04)//*取地址内的内容

打开pc13对应的时钟

#define RCC_BASE   (AHBPERIPH_BASE+0x1000)

#define RCC_APB2ENR    *(unsigned int*)(RCC_BASE+0x18)

#include"stm32f10x.h"
 
int main()
 {
  // RCC_APB2ENR |=(1<<4);
       
RCC_APB2ENR |= 1<<4;
	 GPIOC_CRH &=~(0x0F)<<(4*5);
	 GPIOC_CRH |=(1<<(4*5));
	 GPIOC_ODR &=~(1<<13);
	 
	 //*(unsigned int*)0x4001100C |=(1<<13);
	 while(1);
 }	 
 void SystemInit(void)
 {
	 
 }
#define PERIPH_BASE   ((unsigned int)0x40000000)
	
#define APB2PERIPH_BASE (PERIPH_BASE + 0x10000)
/* AHB×ÜÏß»ùµØÖ·*/
#define AHBPERIPH_BASE    (PERIPH_BASE + 0x20000)

/*GPIOCÍâÉè»ùµØÖ·*/
#define GPIOC_BASE  (APB2PERIPH_BASE + 0X1000)

/*GPIOC¼Ä´æÆ÷µØÖ·*/
#define GPIOC_CRL   *(unsigned int*)(GPIOC_BASE+0x00)
#define GPIOC_CRH   *(unsigned int*)(GPIOC_BASE+0x04)
#define GPIOC_IDR   *(unsigned int*)(GPIOC_BASE+0x08)
#define GPIOC_ODR   *(unsigned int*)(GPIOC_BASE+0x0C)
	
/*RCCÍâÉè»ùµØÖ·*/
#define RCC_BASE  (AHBPERIPH_BASE + 0x1000)

/*RCCµÄAHB2µÄʱÖÓʹÄܼĴæÆ÷µØÖ·*/
#define RCC_APB2ENR  *(unsigned int*)(RCC_BASE+0x18)

//#define RCC_APB2ENR  *(unsigned int*)0x40021018
//#define GPIOC_CRH    *(unsigned int*)0x40011004
//#define GPIOC_ODR    *(unsigned int*)0x4001100C
	

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_lib.h相关头文件 2.0库全部stm32f10x_li
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值