当前位置:网站首页>ARM development (4) How to read the chip manual for novice Xiaobai, bare metal driver development steps and pure assembly to achieve lighting, assembly combined with c lighting, c to achieve lighting
ARM development (4) How to read the chip manual for novice Xiaobai, bare metal driver development steps and pure assembly to achieve lighting, assembly combined with c lighting, c to achieve lighting
2022-08-11 01:56:00 【fly to】
一.How to read the chip manual(datasheet)
as an embedded learner,How to read the chip manual is the top priority.No matter what the chip manual,How hype is written,Its essence is the instruction manual.
可是问题来了,它YThis is the manual in English,But friends who are not good at English should not be too anxious,We now have good translation software,And as long as we read more and read more,Accumulate at a point in the future,Reading the chip manual is no longer a problem for you.
Next, I will use a Samsung chip manual in a vivid image to lead you to read the chip manual together with how to carry out simple driver development,Learn how powerful it is.
二.Bare metal driver development steps
1.When we get a board,If you want to achieve specific functions,The first thing we must think about is to understand what kind of function we want to achieve.(Here, I will take the lighting of lamps that students are annoying to see as an example)
2.Now that we understand that our goal is to light up the lights,Then all we have to do next is find the little light bulb on the board(发光二极管)
如图:
然后我们看到了led【2-5】There are four small bulbs in total
After finding the small light bulb and the name, we officially opened the road to lighting our lights.
Bare metal driver development
(1)看电路图
--1.Find the device I want to control(Take the small light bulb hereled2来举例)
Open our peripheral hardware manual and search in the search barled2
如图
We know from this picture,这是一个npn三极管,The base is connectedcpuside control pinsCHG_COK,由cpuTo perform analog-to-digital conversion to control the high and low potentials,Determines the turn-on and turn-off of the transistor.Here we ignore the already marked onesGPX2_7.
(2)看芯片手册
搜索,The corresponding control module in the circuit diagram,然后如果有coreboardIf so, go there to find the corresponding oneGPX2-7.
看模块的overviewLearn about the approximate functionality of this module.
(3)Look at the control register
What should we do if there are more registers?
See sample programs provided by Technical Support,Find the register that needs to be modified(Often there are only a few).
Some manufacturers provide configuration software,Configure functions through the interface,We just need to use the value of the configured register.
Come to the chip manual,如图所示:
(4)编程
1.A macro that defines the register to be controlled(Corresponds to the register address in the manual)
2.设备初始化(如设置GPIO的输出状态) tips:GPIO就是与cpu相连的引脚
3.Break the functionality into the most basic pieces,逐个实现,如:点亮灯——灭灯——加延时——闪烁——跑马灯
The following code is in thiscpuand implemented on the development board:
cpu:samsung Exynos
开发板: FS4412
三.Pure assembly to achieve lighting
@ GPX2CON 寄存器地址: 0x11000000 + 0x0c40 .text ldr r0, =0x11000c40 @ 将GPX2CONThe register address is moved to r0,那么r0 就代表 GPX2CON ldr r1, [r0] bic r1, #0xf0000000 @ 将 28~31The number bit is cleared orr r1, #0x10000000 @ 28The number bit is set1,The other bits remain unchanged,设置GPX2_7输出功能 str r1, [r0] ldr r0, =0x114001e0 @ 将GPF3CONThe register address is moved to r0 GPF3_4 ldr r1, [r0] @ Get the contents of the address 4字节,相当于取出GPF3CON寄存器的内容 bic r1, #0xf0000 orr r1, #0x10000 str r1, [r0] while: ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] orr r3, #0x80 @ 将GPX2DAT的7号位置 1,亮灯 str r3, [r2] ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] orr r3, #0x10 @ 将GPF3DAT的4号位置 1,亮灯 str r3, [r2] bl delay_1s ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] bic r3, #0x80 str r3, [r2] ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] bic r3, #0x10 @ 将GPF3DAT的4号位置 0,灭灯 str r3, [r2] bl delay_1s b while delay_1s: ldr r10, =0x4ffffff loop: cmp r10, #0 subgt r10, #1 bgt loop mov pc, lr .endmakefile
CROSS=arm-linux- CC=gcc LD=ld OC=objcopy all: $(CROSS)$(CC) -c start.s $(CROSS)$(LD) start.o -Ttext 40008000 -o start.elf $(CROSS)$(OC) -O binary -S start.elf start.bin clean: rm *.o *.elf *.bin
四. assemblyc点灯
mian.c 实现延时
> Created Time: 2022年08月10日 星期三 15时43分06秒 ***********************************************************************/ void delay() { int i, j; for(i = 0; i < 10000; i++) for(j = 0; j < 256; j++); } /*******************************end of file*****************************/@ GPX2CON 寄存器地址: 0x11000000 + 0x0c40 .text ldr r0, =0x11000c40 @ 将GPX2CONThe register address is moved to r0,那么r0 就代表 GPX2CON ldr r1, [r0] bic r1, #0xf0000000 @ 将 28~31The number bit is cleared orr r1, #0x10000000 @ 28The number bit is set1,The other bits remain unchanged,设置GPX2_7输出功能 str r1, [r0] ldr r0, =0x114001e0 @ 将GPF3CONThe register address is moved to r0 GPF3_4 ldr r1, [r0] @ Get the contents of the address 4字节,相当于取出GPF3CON寄存器的内容 bic r1, #0xf0000 orr r1, #0x10000 str r1, [r0] while: ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] orr r3, #0x80 @ 将GPX2DAT的7号位置 1,亮灯 str r3, [r2] ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] orr r3, #0x10 @ 将GPF3DAT的4号位置 1,亮灯 str r3, [r2] bl delay @ 调用main.c中的delay函数,进行延时 ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] bic r3, #0x80 str r3, [r2] ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] bic r3, #0x10 @ 将GPF3DAT的4号位置 0,灭灯 str r3, [r2] bl delay @ 调用main.c中的delay函数,进行延时 b while .endmakefile
CROSS=arm-linux- CC=gcc LD=ld OC=objcopy all: $(CROSS)$(CC) -c start.s $(CROSS)$(CC) -c main.c $(CROSS)$(LD) start.o main.o -Ttext 40008000 -o start.elf $(CROSS)$(OC) -O binary -S start.elf start.bin clean: rm *.o *.elf *.bin
五.c实现点灯,This method is what we use the most,Also the easiest
main.c
***********************************************************************/ void delay() { int i, j; for(i = 0; i < 10000; i++) for(j = 0; j < 256; j++); } #define GPX2CON *(volatile unsigned int *)0x11000c40 #define GPX2DAT *(volatile unsigned int *)0x11000c44 void led2_init() { // GPX2CON = GPX2CON & 0x0fffffff | (1 << 28) GPX2CON = GPX2CON & (~(0xf << 28)) | ( 0x1 << 28 ); } void led2_on() { GPX2DAT = GPX2DAT | (1 << 7); } void led2_off() { GPX2DAT = GPX2DAT & (~(1 << 7)); } int main() { led2_init(); while(1){ led2_on(); delay(); led2_off(); delay(); } } /*******************************end of file*****************************/.text b main .endmakefile
CROSS=arm-linux- CC=gcc LD=ld OC=objcopy all: $(CROSS)$(CC) -c start.s $(CROSS)$(CC) -c main.c $(CROSS)$(LD) start.o main.o -Ttext 40008000 -o start.elf $(CROSS)$(OC) -O binary -S start.elf start.bin clean: rm *.o *.elf *.bin
六.Pure assembly to achieve marquee
@ GPX2CON 寄存器地址: 0x11000000 + 0x0c40 .text ldr r0, =0x11000c40 @ 将GPX2CONThe register address is moved to r0,那么r0 就代表 GPX2CON ldr r1, [r0] bic r1, #0xf0000000 @ 将 28~31The number bit is cleared orr r1, #0x10000000 @ 28The number bit is set1,The other bits remain unchanged,设置GPX2_7输出功能 str r1, [r0] ldr r0,=0x11000c20 ldr r1,[r0] bic r1,#0xf orr r1,#0x1 str r1,[r0] ldr r0, =0x114001e0 @ 将GPF3CONThe register address is moved to r0 GPF3_4 ldr r1, [r0] @ Get the contents of the address 4字节,相当于取出GPF3CON寄存器的内容 bic r1, #0xf0000 orr r1, #0x10000 str r1, [r0] ldr r0,=0x114001E0 ldr r1,[r0] bic r1,#0xf00000 orr r1,#0x100000 str r1,[r0] while: @开灯led2 ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] orr r3, #0x80 @ 将GPX2DAT的7号位置 1,亮灯 str r3, [r2] bl delay_1s @开灯led3 ldr r2,=0x11000c24 ldr r3,[r2] orr r3,#0x1 str r3,[r2] bl delay_1s @开灯led4 ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] orr r3, #0x10 @ 将GPF3DAT的4号位置 1,亮灯 str r3, [r2] bl delay_1s @开灯led5 ldr r2,=0x114001E4 ldr r3,[r2] orr r3,#0x20 str r3,[r2] bl delay_1s @关灯led2 ldr r2, =0x11000c44 @ 将GPX2DATThe address of the register is moved to r2 ldr r3, [r2] bic r3, #0x80 str r3, [r2] bl delay_1s @关灯led3 ldr r2,=0x11000c24 ldr r3,[r2] bic r3,#0x1 str r3,[r2] bl delay_1s @关灯led4 ldr r2, =0x114001e4 @ 将GPF3DAT ldr r3, [r2] bic r3, #0x10 @ 将GPF3DAT的4号位置 0,灭灯 str r3, [r2] bl delay_1s @关灯led5 ldr r2,=0x114001E4 ldr r3,[r2] bic r3,#0x20 str r3,[r2] bl delay_1s b while delay_1s: ldr r10, =0x4ffffff loop: cmp r10, #0 subgt r10, #1 bgt loop mov pc, lr .endmakefile
CROSS=arm-linux- CC=gcc LD=ld OC=objcopy all: $(CROSS)$(CC) -c start.s $(CROSS)$(LD) start.o -Ttext 40008000 -o start.elf $(CROSS)$(OC) -O binary -S start.elf start.bin clean: rm *.o *.elf *.bin
边栏推荐
- Vim take on a window.
- 进程间通信(IPC)的分类以及通信方式的发展
- SQL statement--get database table information, table name, column name, description comment, etc.
- Sub-database sub-table ShardingSphere-JDBC notes arrangement
- ora-00001违反唯一约束
- 联盛德W801系列5-微信小程序与W801蓝牙通信例程(阅读笔记)
- 单面PCB布线阻抗的工程设计
- 络达开发---自定义Timer的实现
- 想进阿里?先来搞懂一下分布式事务
- 项目构建工具-Gradle入门
猜你喜欢

数据库数据采集利器FlinkCDC

进程间通信方式(2)有名管道

ARM开发(四)新手小白如何阅读芯片手册,裸机驱动开发步骤以及纯汇编实现点灯,汇编结合c点灯,c实现点灯
![[ASM] The relationship between the role of the bytecode operation ClassWriter COMPUTE_FRAMES and visitMaxs](/img/28/66370d46ebeb1e16b56ea2a36fe100.jpg)
[ASM] The relationship between the role of the bytecode operation ClassWriter COMPUTE_FRAMES and visitMaxs

SQL statement--get database table information, table name, column name, description comment, etc.

年薪30W,BAT抢着要,懂面试技巧的测试人究竟多吃香?

通过热透镜聚焦的高斯光束

阿里的数据同步神器——Canal

Matlab矩阵(数组)元素过滤常见方法详解
![#yyds Dry Goods Inventory#[Yugong Series] August 2022 Go Teaching Course 008-Integer of Data Types](/img/24/062b17ca125703496808867bd4ada3.png)
#yyds Dry Goods Inventory#[Yugong Series] August 2022 Go Teaching Course 008-Integer of Data Types
随机推荐
如何防止离职员工把企业文件拷贝带走?法律+技术,4步走
[The method of calling the child page from the parent page of the iframe] Stepping on the pit: It is the key to use `[x]` when getting elements. You cannot use `.eq(x)`, otherwise it will not be obtai
Data Analysis Interview Manual "SQL"
单面PCB布线阻抗的工程设计
两日总结十
#yyds Dry Goods Inventory#[Yugong Series] August 2022 Go Teaching Course 008-Integer of Data Types
连流量染色都没有,你说要搞微服务?
软件测试面试题:什么是α测试,β测试?
Engineering Design of Single-sided PCB Routing Impedance
数据的存储(下)——浮点型在内存中的存储
zerorpc:async=True can be written as **{“async“: True}
Deep Learning【第二章】
Qt 中的隐式共享
报错处理:org.xml.sax.SAXParseException: 不允许有匹配 “[xX][mM][lL]“ 的处理指令目标
漏洞管理计划的未来趋势
【HFSS学习记录2】腔体滤波器的设计与仿真
从键入网址到网页显示的详细过程
【微波工程学习记录1】功率分配器和定向耦合器
【websocket】
【oops-framework】模板项目【oops-game-kit】使用简介

