当前位置:网站首页>0 basic self-study STM32 (wildfire) - register lit LED
0 basic self-study STM32 (wildfire) - register lit LED
2022-06-29 17:20:00 【Fecter11】
Wildfire register on LED
#if 0
# include<stdio.h>
sbit LED = P0^0;
void main (void)
{
//P0 = 0xFE; // Bus operation
LED = 0; // Bit operation
}
#endif
# include "stm32f10x.h"
void SystemInit(void);
int main (void)
{
// Clock control
*(unsigned int*)0x40021018 |=(1<<(3)); // open GPIOB Port clock
// The output mode
*(unsigned int*)0x40010C00 |=(1<<(4*0)); //CRL Port configuration register , Push pull output
// Data settings
*(unsigned int*)0x40010C0C &=~(unsigned int)(1<<0); //ODR Data output register . Register operation In combination with the schematic diagram, this step is to light up
//*(unsigned int*)0x40010C0C |=(1<<0); // In combination with the schematic diagram, this step is to extinguish
//*(unsigned int*)0x40010C0C &=~(1<<0);// The code in the video is not forcibly converted to (unsigned int)(1<<0) Write it like this , I write this because the video source code generates a warning after compilation , It suggests that we are going to int The value to unsigned int Type of
}
//|=
//&=~
void SystemInit(void)
{
}
// For storage STM32 Register mapping code
// peripherals perirhral
#define PERIPH_BASE ((unsigned int)0x40000000) // Peripheral base address
#define APB1PERIPH_BASE PERIPH_BASE //APB1 Bus base address
#define APB2PERIPH_BASE (PERIPH_BASE + 0x10000) //APB2 Bus address
#define AHBPERIPH_BASE (PERIPH_BASE + 0x20000) //AHB Bus address
#define RCC_BASE (AHBPERIPH_BASE + 0x1000) // Clock bus
#define GPIOB_BASE (APB2PERIPH_BASE + 0x0C00) //GPIOB Bus
#define RCC_APB2ENR *(unsigned int*)(RCC_BASE + 0x18) // Clock enable register
#define GPIOB_CRL *(unsigned int*)(GPIOB_BASE + 0x00) // Port configuration low register
#define GPIOB_CRH *(unsigned int*)(GPIOB_BASE + 0x04) // Port configuration high register
#define GPIOB_ODR *(unsigned int*)(GPIOB_BASE + 0x0C) // Port output data register

What we do is PB0
Notice that there's a BUG, our ODR The initial value of the register after reset is 0x0000 0000
This is equivalent to saying ODR0 Also reset to 0. Even if we block what we wrote above ODR&=~(1<<0) This line of code ,LED Still lit . So try to avoid the impact of this reset operation .
Here's another point . That is the order of register configuration , Configure the clock first , Reconfigure input / Output , Then give the data . Otherwise, it is possible to GPIO There is no output .
边栏推荐
- 【南京大学】考研初试复试资料分享
- 自动收售报机
- mysql如何查询表的字符集编码
- 卷妹带你学jdbc—2天冲刺Day1
- 底层内功修养
- The fixed assets management system enables enterprises to dynamically master assets
- What role does the supply chain management system play in the supply chain scenario?
- How to establish and use KUKA subroutines / functions
- Inheritablethreadlocal resolves message loss during message transmission between parent and child threads in the thread pool
- Subgraphs in slam
猜你喜欢

底层内功修养

Word2vec vector model of Wiki Chinese corpus based on deep learning

mysql查询视图命令是哪个

手把手教你在windows上安装mysql8.0最新版本数据库,保姆级教学

Subgraphs in slam

基于汇编实现的流载体的LSB隐藏项目

ICML 2022 | 基于解耦梯度优化的可迁移模仿学习方法

Leetcode daily question - 535 Encryption and decryption of tinyurl

Calibration of monocular camera and binocular camera with kalibr calibration tool

linux中mysql 1045错误如何解决
随机推荐
手把手教你在windows上安装mysql8.0最新版本数据库,保姆级教学
mysql视图能不能创建索引
【R语言数据科学】:文本挖掘(以特朗普推文数据为例)
机器人不需要保养和出界也能拿金牌是一样一样的
深圳内推 | 深圳计算科学研究院招聘机器学习助理工程师(校招)
卷妹带你学jdbc—2天冲刺Day1
Simulink simulation mode
基于深度学习的Wiki中文语料词word2vec向量模型
腾讯云发布自动化交付和运维产品Orbit,推动企业应用全面云原生化
在线文本数字识别列表求和工具
First batch! Tencent cloud's ability to pass the solution of the government affairs collaboration platform of the China Academy of ICT
关于Go中两个模块互相调用的场景解决方案
首批!腾讯云通过中国信通院政务协同平台解决方案能力评估
Fluent的msh格式网格学习
It is the same that robots can win gold medals without maintenance and out of bounds
Scenario solution for two modules calling each other in go
mysql在linux中2003错误如何解决
我的远程办公初体验 | 社区征文
Multi mode concurrent implementation of tortoise and rabbit race in go language
PancakeSwap技术:夹子机器人系统开发原理